2015-11-06 62 views
1

我需要在json中存儲多行img src代碼以便在jQuery中使用,但是語法有些問題。所以如果我只存儲一條這樣的線JSON多行圖像代碼

{ 
     "captionthree": 

     "<img class=\"smallicon\" src=\"logos/3dmax.png\" height=\"20px\" width=\"20px\" title=\"3D Stuio Max\">" 

} 

它的工作原理。

但如果我把多條線路也沒有:

{ 
     "captionthree": 

     "<img class=\"smallicon\" src=\"logos/3dmax.png\" height=\"20px\" width=\"20px\" title=\"3D Stuio Max\"> 
     <img class=\"smallicon\" src=\"logos/zbrush.png\" height=\"20px\" width=\"20px\" title=\"ZBrush\"> 
     <img class=\"smallicon\" src=\"logos/topogun.png\" height=\"20px\" width=\"20px\" title=\"Topogun\"> 
     <img class=\"smallicon\" src=\"logos/vray.png\" height=\"20px\" width=\"20px\" title=\"V-Ray\"> 
     <img class=\"smallicon\" src=\"logos/mari.png\" height=\"20px\" width=\"20px\" title=\"MARI Foundry\"> 
     <img class=\"smallicon\" src=\"logos/photoshop.png\" height=\"20px\" width=\"20px\" title=\"Adobe Photoshop\">", 

} 

這裏是jQuery的線,我將其插入:

$('#captionthree').html(database[globalswitchNumber].captionthree); 
+1

你是什麼意思,它不起作用?控制檯上是否有錯誤? – alkis

+0

不,沒有錯誤,我的意思是,json多線代碼不會經過多線代碼,但如果我只使用一行 - 它的工作原理 –

+0

嘗試將所有圖像放在一行中。刪除新行。 – alkis

回答

0

每個圖像標記之前取出新線。由於新行不被處理爲一個字符串。