I need to change (just) the h3
tag to h2
, keeping all default html elements inside, this code are erasing all html contents !!
<script type="text/javascript">
$(function () {
$('.sideMenu h3').replaceWith(function () {
return "<h2>" + $(this).text() + "</h2>";
});
});
</script>
<div class="sideMenu">
<h3 class="sapanos">
<span></span>
<a href="#" title="Sainos">Sapanos</a>
</h3>
</div>
Use .html()
to keep all the HTML structure. text()
just gets the plain text, and throws away all the tags.
$('.sideMenu h3').replaceWith(function () {
return "<h2>" + $(this).html() + "</h2>";
});
To keep the classes, do:
$('.sideMenu h3').replaceWith(function() {
return $("<h2>", {
class: this.className,
html: $(this).html()
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With