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();