I have this code that doesn’t work, can you help me? I want that I changed tag name “p” of class=”s7″ to “h1”
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".s7").replaceWith($('<h1>' + $(this).html() + '</h1>');
});
</script>
The problem is that you’re matching all the elements with class
s7, but you need to process them one by one in order to copy their content into new elements. In your current code,thisis alwaysdocument, not the current element.You can use each() to iterate over the matched elements:
Or maybe: