获取所选元素的外部HTML

非 Y 不嫁゛ 提交于 2020-08-17 19:08:47

问题:

I'm trying to get the HTML of a selected object with jQuery. 我正在尝试使用jQuery获取选定对象的HTML。 I am aware of the .html() function; 我知道.html()函数; the issue is that I need the HTML including the selected object (a table row in this case, where .html() only returns the cells inside the row). 问题是我需要包含所选对象的HTML(在这种情况下为表格行,其中.html()仅返回行内的单元格)。

I've searched around and found a few very 'hackish' type methods of cloning an object, adding it to a newly created div, etc, etc, but this seems really dirty. 我四处搜寻,发现了一些克隆对象,将其添加到新创建的div等中的非常“ hackish”类型的方法,等等,但这似乎很脏。 Is there any better way, or does the new version of jQuery (1.4.2) offer any kind of outerHtml functionality? 有没有更好的方法,还是新版本的jQuery(1.4.2)提供了任何一种outerHtml功能?


解决方案:

参考一: https://stackoom.com/question/A9UD/获取所选元素的外部HTML
参考二: https://oldbug.net/q/A9UD/Get-selected-element-s-outer-HTML
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!