- 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.
推薦閱讀
- R語言經典實例(原書第2版)
- Raspberry Pi Networking Cookbook(Second Edition)
- Python爬蟲開發:從入門到實戰(微課版)
- PyQt從入門到精通
- TypeScript圖形渲染實戰:基于WebGL的3D架構與實現
- 實戰Java高并發程序設計(第3版)
- Python機器學習經典實例
- H5頁面設計:Mugeda版(微課版)
- RSpec Essentials
- AutoCAD 2009實訓指導
- ASP.NET程序開發范例寶典
- 進入IT企業必讀的324個Java面試題
- Clojure Data Structures and Algorithms Cookbook
- ANSYS FLUENT 16.0超級學習手冊
- C# 10核心技術指南