Site Moved

This site has been moved to a new location - Bin-Blog. All new post will appear at the new location.


CreateDOM - $C() - Fixed

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.

See Demo...

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...

  li:'First Item.',
  li:'Second Item..',
  li:'Third Item...'

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...

  li1:'First Item.',
  li2:'Second Item..',
  li3:'Third Item...'

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.