问题:
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
来源:oschina
链接:https://my.oschina.net/u/3797416/blog/4328284