I have span with id "bar".which contains tag <h3></h3> and I want to replace <h3></h3> with "some string". Here is my html
<span id="bar" >
<h3></h3>
</span>
Output I am expecting as
<span id="bar" >
some string
</span>
Many Thanks..
You can use html method:
$('#bar').html('some string');
If you want to just replace the h3 element, you can use replaceWith method:
$('#bar h3').replaceWith('some string');
html() method, but maybe the span will contains some other tags which should not be replaced and I think the best method is to use replaceWith() method