admin管理员组文章数量:1406060
I have the next input element:
<input type="text" name="username" id="username" value="user name"
helper="formText" defvalue="user name" class="filling" />
How can I get this html by id "username"
with help of jQuery?
I try to make it with get()
, html()
. But I want to get html of current element.
Thank you in advance.
Sorry for my english.
I have the next input element:
<input type="text" name="username" id="username" value="user name"
helper="formText" defvalue="user name" class="filling" />
How can I get this html by id "username"
with help of jQuery?
I try to make it with get()
, html()
. But I want to get html of current element.
Thank you in advance.
Sorry for my english.
Share Improve this question edited Aug 25, 2014 at 3:52 chiwangc 3,57716 gold badges27 silver badges32 bronze badges asked Dec 23, 2010 at 10:05 Alex PliutauAlex Pliutau 22k28 gold badges114 silver badges144 bronze badges 1- So you want the HTML of the input tag? – lonesomeday Commented Dec 23, 2010 at 10:07
1 Answer
Reset to default 6You can't get the exact HTML (as different browsers handle this differently), but closest you can get is appending a cloned version to a temporary element and taking the .innerHTML
of that, like this:
var html = $("<div/>").append($("#username").clone()).html();
本文标签: javascriptjQuery get current element (x)htmlStack Overflow
版权声明:本文标题:javascript - jQuery get current element (x)html - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744959695a2634577.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论