我一直在尝试使用.html()或.append()函数来呈现通过ajax调用从第三方插件返回的标记。
ajax响应(返回正常)如下所示:
<div>
<!-- Start Third Party Markup -->
<div>
<img id="Img1" usemap="#dnc_map_43" src="charts/solution_id_6/dnc-vvvgdwwl.png?634336319915542170" style="height:294px;width:628px;border-width:0px;" />
<map name="dnc_map_43" id="Map1">
<area shape="poly" coords="0,274,628,274,628,294,0,294" href="http://www.dotnetcharting.com" alt="Visit .netCHARTING for licensing options and more information." title="Visit .netCHARTING for licensing options and more information." />
<area shape="poly" coords="381,26,616,26,616,56,381,56" href="http://www.dotnetcharting.com" alt="Visit .netCHARTING for licensing options and more information." title="Visit .netCHARTING for licensing options and more information." />
</map>
</div>
<!-- End Third Party Markup -->
</div>但是,我们无法控制来自第三方的标记的格式化方式,我发现(在费尽心机一上午之后),.html()或.append() jQuery函数要求标记要么在一行中,要么在每个新行字符后使用"\“进行转义。
有谁知道解决这个问题的方法吗?
发布于 2011-02-18 21:53:57
this能解决你的问题吗?如果没有,请纠正我。
发布于 2011-02-18 21:57:54
我已经用jquery 1.5运行了下面的测试,它对我来说工作得很好。
<div id="one">
<P>foo</p>
<p>bar</p>
</div>
<div id="two"></div>
$('#two').html( $('#one').html() );第二个div正确地填充了第一个div中的多行标记。
https://stackoverflow.com/questions/5042048
复制相似问题