2015-11-06 59 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

每个图像标记之前取出新线。由于新行不被处理为一个字符串。