foreach (var item in products)
{
contantProduct += "<br/> <div class='linkProduct' id=\"link" + item.IdProduct + "\" onclick=\"$('.linkFlashIco').css('background-image','url(icon/Pointer.png)');$(this).find('>:first-child').css('background-image','url(icon/Activepointer.png)'); $(this).find('>:first-child').css('background-repeat','no-repeat'); $('.linkProduct').css('font-weight','normal');$('.linkProduct').css('border','1px solid orange');$('.linkProduct').css('background-color','white');$(this).css('border','1px solid blue');$(this).css('background-color','red');$(this).css('font-weight','bold');$('.detailProduct').slideUp();$(\'#" + item.IdProduct + "\').slideToggle('normal');\" id=\"link" + item.IdProduct + "\" style='text-align: right;cursor: pointer;float: right;padding-right: 2px;border:1px solid orange;text-decoration:none' > <font face='Tahoma'>" + item.NameProduct + "</font><div class='linkFlashIco' style='background-image: url(icon/Pointer.png); background-repeat: no-repeat;float: right;width: 18px;height: 20px;'></div></div>";
}
如何在多行中编写contantProduct
我喜欢写
contantProduct+="<br/><div"
+"....."
+"...."
答案 0 :(得分:2)
使用@
contantProduct + = @“
&LT峰; br /&GT;
&lt; div class ='linkProduct'id =“”link“”
...等 “;
答案 1 :(得分:0)
如果我了解你的目标,你可以在这里找到一些答案.... Multiline strings in Javascript
答案 2 :(得分:0)
您可以使用ejs或http://jade-lang.com/作为模板引擎。除非您想要转义换行符,否则JavaScript本身不支持多行字符串。
var str = "some text \
Some more text";