jQuery replaceWith Method

jQuery replaceWith method : is used to replace the selected element with another element. This method replaces the existing content with selected content. We are going to explain this method with example and demo.



jQuery replaceWith Method Example

jQuery replaceWith() Method – Example

<script type="text/javascript">
              $( "#replaceExample" ).on( "click", function(event) {             
                $("#oldDiv").replaceWith("<div style='padding:20px;background:blue;'>I M New One.</div>");               

Try it »

The above example will produce the following output-

jQuery replaceWith Method


Add Comment

📖 Read More