Alex
Alex

Reputation: 163

jQuery remove h1 text

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

Answers (3)

The Alpha
The Alpha

Reputation: 146191

To remove the tag

$("nobr.testClass > h1").remove();

To empty the tag

$("nobr.testClass > h1").empty();

Upvotes: 2

Milind Anantwar
Milind Anantwar

Reputation: 82241

try this:

   $(".testClass h1").text('');

and for deleting:

   $(".testClass h1").remove();

Upvotes: 4

Alex
Alex

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

Related Questions