-
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 10 years, 4 months ago by
Sourabh.
-
This discussion was modified 10 years, 3 months ago by
Forcetalks.
-
This discussion was modified 10 years, 4 months ago by
Log In to reply.
Popular Salesforce Blogs
Salesforce App Development: Best Practices
One of the great things about Salesforce is its infinite customization options. Not only can you tailor it to suit your unique business needs but…
Top Reasons to Attend Dreamforce 2024
Table of Contents Top Reasons to Attend Dreamforce 2024 Cutting-Edge Keynotes and Sessions Learn the Hows and Whys of Trusted AI Be on the…
Salesforce Apex Winter Release 21 - All You Need To Know
1. Before Apex Winter Release 21 batch limit for big objects using deleteImmediate() is 2,000 records at a time. Now we can delete up to…
Popular Salesforce Videos
What is Salesforce? What Does it Do?
Business is rapidly changing. In this digital age, everything and everyone is connected, which is changing the way we communicate with our consumers. Businesses nowadays…
What Is Salesforce? | Salesforce Training - What Does Salesforce Do?
What is Salesforce? Salesforce is a cloud computing service as a software (SaaS) company that specializes in customer relationship management (CRM). Salesforce's services allow businesses…
How to Focus on Report Results in Salesforce Console | Salesforce
When you work with reports in a fast-paced Salesforce Console environment, every extra click or focus change can slow you down. Now a streamlined console…