如何在jquery中获取匹配元素的html
我有这个html,
<div id"test123">
dasd'asdasd
</div>
我想要那个div框的内容与 "
"
本身,而不仅仅是innerhtml我尝试了 $('#test123') .html()
但它只给了我内部 html
I have this html
<div id"test123">
dasd'asdasd
</div>
I want the content of that div box with "<div id="test123">"
itself as well not just innerhtml
I tried $('#test123').html()
But it only gave me inner html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
另一种选择,对我来说看起来更线性/更好:
<代码>
found here:
http://codeasp.net/blogs/raghav_khunger/microsoft-net/751/jquery-how-to-get-html-of-a-div-with-that-div-tag-included
Another alternative, which looks more linear/nicer to me:
found here:
http://codeasp.net/blogs/raghav_khunger/microsoft-net/751/jquery-how-to-get-html-of-a-div-with-that-div-tag-included
在盒子里似乎不是一个简单的方法。
http://brandonaaron.net/blog/2007/06/17 /jquery-snippets-outerhtml/
Doesn't seem to be an easy way in the box.
http://brandonaaron.net/blog/2007/06/17/jquery-snippets-outerhtml/
相当粗糙,但它完成了工作:
Pretty gnarly, but it gets the job done: