O'Reilly logo

ASP.NET jQuery Cookbook - Second Edition by Sonal Aneel Allana

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

Adding/removing DOM elements

This recipe demonstrates how to clone elements on the DOM. We will also see how to remove elements completely from the DOM tree. The programming constructs used in this example are summarized in the following table:

Construct

Type

Description

$("#identifier")

jQuery selector

This selects an element based on its ID

$("html_tag")

jQuery selector

This selects all elements with the specified HTML tag.

.addClass()

jQuery method

This adds the specified CSS class to each matched element.

.attr("name") or

.attr("name", "value")

jQuery method

This returns a string with the required attribute value of the first matched element. It can also be used to set the attribute to the required value.

[attribute= ...

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