-
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, 8 months ago by Sourabh.
- This discussion was modified 8 years, 7 months ago by Forcetalks.
Log In to reply.
Popular Salesforce Blogs
Lightning Design Experience In Visualforce Pages with Lightning CSS Framework
Salesforce Lighting Design System(SLDS) is a CSS framework introduced by Salesforce to create faster,responsive and beautiful pages even in Salesforce Classic. This css framework is…
Common Salesforce User Engagement Issues In The Workplace
The success of the Salesforce implementation depends on how efficiently its end users are using the platform. Any Salesforce user engagement issues can cause serious…
From Nice-to-have to Necessity : The Role of Personalization in Banking | Salesforce
Over 79% of U.S. consumers perceive their relationship with banks as purely transactional. And banks across the country are striving to change that equation. Technology…
Popular Salesforce Videos
Salesforce Financial Services Cloud Spring '23 Highlights
Shake off those winter blues with the new features coming in Salesforce's Spring '23 Release for Financial Services Cloud. Whether it's ARC enhancements, interaction summary…
How to Create Your First Salesforce Lightning Component?
OpFocus walks through the steps you need to know to create your first Salesforce Lightning Component.
How To Build Better Communities with Salesforce Lightning?
Learn how you can customize Salesforce Community Cloud to fit your needs with the Lightning Bolt framework, Lightning Components and Community Builder.