I have an unordered list containing many items called 'olist items', which are a square of ul but no id
I want to each. Once the OListItem class is retrieved, add an ID to it dynamically.
var o = $ (". OListItem"); $ .eich (o, function) {var f = $ (this) .attr ("id", 'listItem' + i); I ++;});
To make sure about the approach, do I have it so far?
You can use this (from the element of the collection), note that id number does not start with Can:
$ ('. OListItems'). Each (function (i) {$ (this) .attr ('id', 'listItem' + i);});
The, (index, element)
, you already need in this case, the i
index (zero-based) current You are on .oListItem
.
Comments
Post a Comment