The each() method supplies two parameters to the callback-function. They are current index and the current item. Thus you could do the following:
$('ul#mylist > li').each((i, v) => {
$(v).addClass('some-class-name');
});
Where the “v” variable is the current “li” element
More Related Contents:
- Are ‘Arrow Functions’ and ‘Functions’ equivalent / interchangeable?
- What’s the meaning of “=>” (an arrow formed from equals & greater than) in JavaScript?
- When should I use a return statement in ES6 arrow functions
- ECMAScript 6 arrow function that returns an object
- What does “this” refer to in arrow functions in ES6?
- When should I use arrow functions in ECMAScript 6?
- What do multiple arrow functions mean in JavaScript?
- Why doesn’t my arrow function return a value?
- Using jQuery $(this) with ES6 Arrow Functions (lexical this binding)
- Arrow function without curly braces
- Curly Brackets in Arrow Functions
- Why shouldn’t JSX props use arrow functions or bind?
- How do I write a named arrow function in ES2015?
- What are the differences (if any) between ES6 arrow functions and functions bound with Function.prototype.bind?
- Official information on `arguments` in ES6 Arrow functions?
- Arrow Functions and This [duplicate]
- Using _ (underscore) variable with arrow functions in ES6/Typescript
- ES6 arrow functions not working on the prototype?
- Arrow Function in Object Literal [duplicate]
- What does arrow function ‘() => {}’ mean in Javascript? [duplicate]
- JavaScript ES6: Test for arrow function, built-in function, regular function?
- Can I use arrow function in constructor of a react component?
- Can I use ES6’s arrow function syntax with generators? (arrow notation)
- Immediate function using JavaScript ES6 arrow functions
- ESCMAScript 6 arrow functions – parentheses around parameter
- ES6 functions, arrow functions and ‘this’ in an ES6 class [duplicate]
- Why can I not use `new` with an arrow function in JavaScript/ES6?
- How can I differentiate between an arrow function, class and a normal function?
- Why is `throw` invalid in an ES6 arrow function?
- Is it possible to export Arrow functions in ES6/7?