我有一个包含单引号和双引号混合的字符串。 You can see here。首先,如果我尝试制作该字符串的jquery对象,我会分解href和它的页面链接。这两个部分的行为类似于标记的属性,附加的双引号附加了页面的链接部分。像$(mystr)的控制台= ... href =“”display.aspx“”“其中display.aspx是页面的链接。但是当我尝试href = \'display.aspx \'时,我能够得到我如何摆脱属性问题的这个分区?在jsfiddle上给出的代码是
var s= "<tr role=\"row\" id=\"1\" tabindex=\"-1\" class=\"ui-widget-content jqgrow ui-row-ltr\"><td role=\"gridcell\" style=\"\" title=\"Albania\" aria-describedby=\"mytabl_Country\">Albania</td><td role=\"gridcell\" style=\"text-align:center;\" title=\"\" aria-describedby=\"mytabl_Nutrition related\"><img class=\"resultsGridImage\" src=\"Images/check.png\" oldtitle=\"Click on reference ID to view details:<ol><li>ID: <a target=\'_blank\' href=\"DisplayRefmat.aspx?NOPAID=241\">241</a>, Analyses of the situation and national action plan on food and nutrition for Albania 2003-2008</li> <li>ID: <a target=\'_blank\' href=\"DisplayRefmat.aspx?NOPAID=826\">826</a>, Towards a healthy country with healthy people - Public health and health promotion strategy</li> <li>ID: <a target=\'_blank\' href=\"DisplayRefmat.aspx?NOPAID=827\">827</a>, Analyses of the State of Food and Nutrition in Albania</li> <li>ID: <a target=\'_blank\' href=\"DisplayRefmat.aspx?NOPAID=828\">828</a>, Recommendation on healthy nutrition in Albania</li> </ol>\"></td></tr>";
console.debug($(s));
$('#btable').append(s);
答案 0 :(得分:1)
也许我在想这里简单化了,但是当我看到上面的代码时会想到这一点:
var s= "<tr role=\"row\" id=\"1\"....</tr>";
可以写成
var s= "<tr role='row' id='1'...</tr>";
为什么在字符串中使用双引号?