使用结束标记获取确切的html(),其中缺少开始标记 [英] Get exact html() with closing tag for which starting tag is missing

查看:114
本文介绍了使用结束标记获取确切的html(),其中缺少开始标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前正在使用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);}); 

查看DEMO


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);});

See DEMO

这篇关于使用结束标记获取确切的html(),其中缺少开始标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆