- JavaScript:Moving to ES2015
- Ved Antani Simon Timms Narayan Prusty
- 122字
- 2021-07-09 19:07:42
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.
推薦閱讀
- LabVIEW 2018 虛擬儀器程序設計
- Manga Studio Ex 5 Cookbook
- FFmpeg入門詳解:音視頻流媒體播放器原理及應用
- 劍指大數據:企業級數據倉庫項目實戰(在線教育版)
- PHP+Ajax+jQuery網站開發項目式教程
- Hands-On Nuxt.js Web Development
- Java Web從入門到精通(第2版)
- Java Web應用開發給力起飛
- Applied Deep Learning with Python
- 分布式數據庫HBase案例教程
- 和孩子一起學編程:用Scratch玩Minecraft我的世界
- HTML5 Game Development by Example:Beginner's Guide(Second Edition)
- Jenkins 2.x實踐指南
- Swift編程實戰:iOS應用開發實例及完整解決方案
- C語言開發寶典