This repository was archived by the owner on Jun 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
$.all()
Arthur Guiot edited this page Jul 6, 2017
·
1 revision
Do you know the .each() function in jQuery? Well, the $.all() is almost the same. You simply select elements and it will iterate the same action through each element selected.
It's super simple, you simply have to give it a list of elements (to do this, simply use this model: $.select(".myClass")), and the action as a callback.
Let's say you have 2 button executing the same action.
HTML:
<button class="firstButton buttonForActionX"></button>
<button class="secondButton buttonForActionX"></button>JS:
$.all($.select(".buttonForActionX"), function(element) {
$.on(element, "click", () => { alert("You clicked on me") }); // Using ES6, but only because this time it's more readable.
});Don't hesitate to ask your questions
- Home
- The Core Languages
- Getting Started: Installation
- The Basics (
$.var()+$.target()) - Developing for DisplayJS
-
$.select()- Text related
- If...else
$.xss()$.repeat()$.custom()$.live()$.load()$.on()$.onEvent()$.ready()- Scroll API
$.all()$.clone()$.is()$.valEmpty()$.remove()$.show()&$.hide()$.ajax()- Class Related
$.css()$.getStyle()- Fade effects
$.extend()$.dynamic()$.parent()- Elements-Nodes
$.component()$.time_ago()$.copy()$.then()$.sleep()$.getProp()