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

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.

主站蜘蛛池模板: 大石桥市| 江阴市| 德江县| 漳平市| 政和县| 潞城市| 曲阳县| 和田市| 泸溪县| 海南省| 台东县| 平武县| 西丰县| 孝义市| 太仆寺旗| 石首市| 宜都市| 健康| 拉孜县| 阳信县| 错那县| 嘉峪关市| 尤溪县| 桃江县| 卢氏县| 金湖县| 岳普湖县| 穆棱市| 平顶山市| 昌平区| 河西区| 凯里市| 和平区| 五家渠市| 报价| 耒阳市| 镇雄县| 耿马| 郎溪县| 富顺县| 讷河市|