Reputation: 163
i have this html line:
<nobr title="New" class="testClass">
<h1>ABC</h1>
</nobr>
How can i remove the text inside h1 or remove the whole h1 tag?
my last try:
$("nobr.testClass > h1").text('');
But this dont work
Upvotes: 3
Views: 8537
Reputation: 146191
To remove the tag
$("nobr.testClass > h1").remove();
To empty the tag
$("nobr.testClass > h1").empty();
Upvotes: 2
Reputation: 82241
try this:
$(".testClass h1").text('');
and for deleting:
$(".testClass h1").remove();
Upvotes: 4
Reputation: 35409
The following removes the h1
element:
$("nobr.testClass > h1").remove();
Though, your code should be working as written. Your error is elsewhere.
Upvotes: 6