jQuery

Having settled on jQuery for a front-end JavaScript library (although possibly YUI for admin interfaces), I’m just going to collect little snippets of wisdom.

Replace function

It seems like replace is the missing function, however, with jQuery syntax it’s easier than you might have thought:

$("#oldElement").after(newElement).remove(); 

And if you really want a replace function, this was suggested as a pluggin:

$.fn.replace = function(o) { return this.after(o).remove(); }; 

Leave a Reply

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