I have next html:
<label for="user_name">
<abbr title="required">*</abbr>
Name
</label>
And I want to change label caption to Title with jquery. So I do
$('label[for=user_name]').html('Title')
And it replaces all inner html (including abbr tag)
So, what’s the easiest way to replace only Name?
If you use
contents()method it will also return text nodes. Since jQuery doesn’t have text node methods, convert last node to a DOM nodeDemo: http://jsfiddle.net/yPAST/1/