Home
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $(document).ready(function () { $("button").click(function () { $("p").replaceWith('<div>Replaced p tag with div</div>'); }); }); </script> </head> <body> <h1>jQuery Manipulation Methods: replaceWith()</h1> <p class="test">This is a paragraph</p> <button>Click Me to test replaceWith()</button> </body> </html>
Result: