replace html - jquery change tag

2 Answers

You're missing a closing parenthesis, and you're using this in the wrong context:

    $(".s7").replaceWith($('<h1>' + $(".s7").html() + '</h1>'));

If you have multiple elements with a class name of s7, use .each():

        $(this).replaceWith($('<h1>' + $(this).html() + '</h1>'));
name javascript id

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">
           $(".s7").replaceWith($('<h1>' + $(this).html() + '</h1>');

jQuery html5 tag change to div

You can use replaceWith method:

   return '<div id="' + + '"></div>'