我有一个包含单引号和双引号的字符串。你可以在这里看到。首先,如果我尝试创建该字符串的 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);