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

Using event delegation to attach events to future controls

This recipe demonstrates event delegation and event bubbling. By adding elements at runtime, we will also demonstrate how delegation helps you attach events to future controls. The constructs used in this example are as follows:

Construct

Type

Description

$("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.

.append()

jQuery method

This attaches elements at the end of each matched element.

[attribute= "value"]

jQuery selector

This selects an element with the specified attribute equal to the value string.

click

jQuery event

This is fired when you ...

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