I have a long list and the person that will be maintaining the site is NOT savvy at anything. So, I would like to write a function that will loop through all the UL elements and add an ID called "content#" where # starts at 0 and increases by 1 each time.
I have tried a number of things with no success.
The reason I would like this to be done by javascript and not manually is that the list is VERY long and the id will need to be added roughly 270 times, if she misses even one number, than the javascript that uses that id will fail to work.
Here is the basic idea, but it doesn't work:
(Yeah, I know I suck at javascript , so don't laugh if that is a feeble attempt.)
Thanks in advance for any help!!
I have tried a number of things with no success.
The reason I would like this to be done by javascript and not manually is that the list is VERY long and the id will need to be added roughly 270 times, if she misses even one number, than the javascript that uses that id will fail to work.
Here is the basic idea, but it doesn't work:
Code:
function addid() {
var g = document.getElementsByTagName('ul');
for(var i=0; i<g.length; i++) {g.id = 'content'+i;}
}
(Yeah, I know I suck at javascript , so don't laugh if that is a feeble attempt.)
Thanks in advance for any help!!