jQuery .html(),. append()不适用于多行标记

1 html jquery

我试图让.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>
Run Code Online (Sandbox Code Playgroud)

但是我们无法控制格式化第三方标记的方式,并且我发现(在整个上午撕掉我的头发之后).html()或.append()jQuery函数要求标记在任何一个中在每个新行字符后使用"\"换行或转义.

有没有人知道这方面的方法?

Gol*_*rol 5

如果确实如此(尽管我很难想象它是),你可以使用该replace方法替换空字符串\n\r使用空字符串.