replaceChild jQuery equivalent
If what you want is to replace the inside:
$(this).empty().append('<p>replacement</p>')
If you want to use pure jQuery you can use the replaceWith method
$(this).replaceWith(newElem);
you can refer this link :
http://api.jquery.com/replaceWith/
You can try this
$(this).parent().get().replaceChild(newElem,this);
If $(this).parent()
is unique on the page. (.get()
gives you the DOM object)
If you want to use pure jQuery
you can use the replaceWith
method
$(this).replaceWith(newElem);
If you want to replace the elements inside the parent, do the following.
This is how to replace ALL children of an element:
$(this).children().replaceWith(<div>hello world</div>)
This is how to replace a specific child of an element by index:
$($(this).children()[3]).replaceWith(<div>hello world</div>)