-
Loop Syntax in jQuery
jQuery 3.0 is the most newest version of jQuery. There are many changes in it, but one of the important change
is the syntax of loop using for..of loop.For example earlier we use the syntax shown below:-
var $divelements = $("div");
for (var x=0; x< $divelements.length; x++){
$divelements[x].addClass("dummy");
}Here's the new syntax:-
var $divelements = $("div");
var i = 0;
for(var elm of $divelements) {
elm.addClass("dummy");
}With the help of this new syntax, you will get DOM elements, instead of jQuery collection. You not need to use index to get element, it will be directly accessible to you.
- This discussion was modified 8 years, 7 months ago by Sourabh.
- This discussion was modified 8 years, 6 months ago by Forcetalks.
Log In to reply.
Popular Salesforce Blogs
Single or Multi-Org - What is your Salesforce Architecture?
While setting up a Salesforce Architecture or assessing the performance of an existing org, the most perplexing question that haunts anyone is to decide between…
Salesforce's Top 10 Summer '21 Release Features
In the digital-first world, things change at the speed of light. New technologies, software, techniques are innovated, upgraded, and updated every day. One must keep…
Change Sets in Salesforce | All You Need to Know
Salesforce is a popular cloud-based CRM platform that offers a wide range of tools and features to help businesses manage their customer relationships more effectively.…
Popular Salesforce Videos
Einstein For Marketing Cloud | The Learning Guide
AI has made things easy and smooth for any automation process. Einstein for Marketing Cloud provides insights and data to inform the content and timing…
Salesforce - Outlook Integration
In this video, Salesforce Atlas explains how to increase your productivity by automatically synchronizing your data between the two systems, creating tasks, associating emails from…
How to Integrate Commerce, Marketing and Service Using Salesforce Customer 360
Developers, Integrators, Admins and Architects all work together to deliver projects that span multiple Salesforce products. Salesforce is making it simpler by providing native integration…