Remember the $C() function from a few days back? More specifically remember the problem that it had? Well, I fixed the problem - but it is more of a hack than an actual solution. $C() is a function that provides a much easier alternative to W3C DOM's createElement function. You can create DOM structures very easily with it.
The problem was that you can't use the same tag twice inside an element. I am using a associative array, so the index will be overwritten. For example...
$C({ul:{
li:'First Item.',
li:'Second Item..',
li:'Third Item...'
}
},"insert-here");
This will create a list of just one item because the index('li') of the associative array is overwritten every time a new item is added. I solved it like this...
$C({ul:{
li1:'First Item.',
li2:'Second Item..',
li3:'Third Item...'
}
},"insert-here");
This approach basically adds some junk data to the index to make it unique. My script will automatically remove all non-alphabet chars at the end of a tag name before making it an DOM element.
To get the corrected script, please go to the CreateDOM page.
0 Comments:
Post a Comment