使用结束标记获取确切的html(),其中缺少开始标记 [英] Get exact html() with closing tag for which starting tag is missing
问题描述
目前正在使用HTML: hello< / div>< p> hai< / p>< span>欢迎< / span>
提醒 $('body')。html()
它提醒 hello< p> hai< / p>< span>欢迎< / span>
。
小提琴
但我希望它显示 hello< / div>< p> hai< / p>< span>欢迎< / span>
strong> ie Alert HTML,因为它是写入正文中的。
当我查看页面的源代码时,我可以看到确切的代码。真的不知道客户端脚本是否能够显示我询问的输出。
是否有可能?如果是,如何?
$。get(window.location.href,function(data){console.log(data);});
Currently for a body with HTML: hello</div><p>hai</p><span>Welcome</span>
on alerting $('body').html()
it alerts hello<p>hai</p><span>Welcome</span>
.
Fiddle
But I want it to display hello</div><p>hai</p><span>Welcome</span>
i.e. Alert HTML as it is written within the body.
I can see the exact code when I view the source-code of the page.I really dont know if client-side scripts are capable of displaying the output I asked.
Is it possible ?And if yes How?
You could make an ajax request, this way the HTML won't be parsed:
$.get(window.location.href,function(data){console.log(data);});
这篇关于使用结束标记获取确切的html(),其中缺少开始标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!