How to get html of cloned element

笑着哭i 提交于 2019-12-04 02:37:37

Try this

var txt=jQuery("input[name="+n+"[]]:first").clone().wrap("<div />").parent().html();

I think you want the outer HTML instead of innerHTML:

var text = $('<div>').append(jQuery("input[name="+n+"[]]:first").clone()).html();

.html() returns the html inside the element. I am guessing you have something like <input name="..."/> which has no inner html.

You should probably rely on something like outerHtml plugin.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!