6
rated 0 times
[
13]
[
7]
/ answers: 1 / hits: 19516
/ 11 Years ago, wed, october 9, 2013, 12:00:00
I'm trying to update a set of divs class=oct_days
to give them id based on :nth-child(n)
. The format of the id
is oct_n
. I'm trying to accomplish this using a for loop to set this for divs.
window.onload = function addOctDate() {
var cls = document.getElementByClass(oct_days);
for (var n = 1; n < 32; n++) {
cls[n].id = oct_ + n;
}
};
Fiddle (http://jsfiddle.net/ascottz/D9Exm/)
The idea is to have .oct_days:nth-child(1)
have id=oct_1
, but id isn't being set.
More From » for-loop