O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Removing Objects from the jQuery Object Set

var items = $("span"); items.css({color:"red"});   //colors text in all <span> elements red items.remove(".menu"): items.css({"font_weight":"bold"});   //set all <span> elements except .menu to bold

Another great feature of jQuery is how easy it is to remove items from and add additional elements to the jQuery object set. The .remove([selector]) method will remove elements  that match the selector from the set represented by the jQuery object. Calling .remove() with no selector will remove all elements from the set.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required