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

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.

主站蜘蛛池模板: 杭锦后旗| 嫩江县| 吉首市| 周口市| 柘城县| 塘沽区| 阿克陶县| 东兰县| 云南省| 侯马市| 清镇市| 岳普湖县| 博罗县| 陕西省| 望奎县| 喀喇| 称多县| 罗江县| 宜昌市| 广州市| 仙游县| 曲松县| 兖州市| 抚远县| 威信县| 皋兰县| 讷河市| 军事| 丰镇市| 普陀区| 铜川市| 万荣县| 天长市| 永平县| 东平县| 平定县| 舒城县| 二手房| 青铜峡市| 山阳县| 奉贤区|