Thougth of a Numeric ID in Jquery

I have devoted some of my time to create a Web Browser Game. This game has a Map (It is just a table with a lot of CSS to make it look like an Real Battle Map)... Well i started to work on it an created each tag with a numeric ID.. heres some code example:














But when I tried to select a ROW from the table by its ID like $('tr#0'), it doesnt work. So debuggin and debuggin I figured out that using a numeric Id in any TAG make jquery crazy. There are two solutions for fixing this behaviour:

A) Use eq to get the element of your desire: Something like $('tr').eq(1) will make the trick

B) Dont use a numeric ID at all: I think this is the best solution, so instead use something like:







Hope it help somebody with the same problem

2 comments:

Unknown said...

Hi there,

IDs aren't valid unless they start with a number, so JQuery is correctly ignoring the id in this case. IDs must begin with a letter - has been the same since SGML!

Jose Carlos Tamayo said...

That's rigth , we cant put numerics ID on DOM elements, unfortunately thats something i didnt know about until now. Thanks for the comments =)