Jquery replaceWith

I got to learn a new jquery code to this time, its “replaceWith”. I think the function is like replacing a component with the component you want.

Code : “$(“#replace_me”).replaceWith( ‘<div id=”replace_me”>New Me</div>’ )”
HTML : “<div id=”replace_me”>OLD Me</div>”

The result going to be “<div id=”replace_me”>New Me</div>” because “OLD Me” div already being replaced with “New Me” div. As simple as it could be.

Leave a Reply

Your email address will not be published. Required fields are marked *