官术网_书友最值得收藏!

Chaining

Chaining jQuery methods allows you to call a series of methods on a selection without temporarily storing the intermediate values. This is possible because every setter method that we call returns the selection on which it was called. This is a very powerful feature and you will see it being used by many professional libraries. Consider the following example:

$( '#button_submit' )
  .click(function() {
    $( this ).addClass( 'submit_clicked' );
  })
  .find( '#notification' )
    .attr( 'title', 'Message Sent' );x

In this snippet, we are chaining click(), find(), and attr() methods on a selector. Here, the click() method is executed, and once the execution finishes, the find() method locates the element with the notification ID and changes its title attribute to a string.

主站蜘蛛池模板: 平昌县| 黔西县| 麦盖提县| 子洲县| 平湖市| 二连浩特市| 扬中市| 仙桃市| 绥江县| 中阳县| 黄石市| 汉中市| 双江| 保定市| 嘉兴市| 太仓市| 巩义市| 电白县| 稻城县| 浏阳市| 唐河县| 义乌市| 通化市| 瑞安市| 义乌市| 永年县| 礼泉县| 蒙山县| 比如县| 资阳市| 遵义市| 民县| 普定县| 拉萨市| 南和县| 武冈市| 旬邑县| 通榆县| 澄迈县| 乌兰浩特市| 万盛区|