jQuery get current element (x)html
I have the next input element:
<input type="text" name="username" id="username" value="user name"
helper="formText" defvalue="user name" class="fill开发者_JAVA技巧ing" />
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.
You 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();
精彩评论