Numbers as ID in web pages isnt working!
I was just wondering why my jquery event woudlnt be triggerd in FireFox when im using Numeric Values in my ID tags
Like ($"#2").live .....
and <div id='2' .....
ive noticed that the events arent triggerd this w开发者_StackOverflow社区ay and only in FireFox. Any explanation is welcome.
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods ("."). Citation: html 4 reference at the W3.
So your id
is not valid, as it starts with a numeric character.
Under HTML 5 however the id
is only required to have:
The id attribute specifies its element's unique identifier (ID). The value must be unique amongst all the IDs in the element's home subtree and must contain at least one character. The value must not contain any space characters.
It isn't valid HTML4
to have IDs that begin with a number.
You must start them with a letter.
Numeric IDs are allowed in HTML5
though.
ID values for html elements must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
It really depends on what ($"#2")
is doing. If it's passing #2
to a querySelector
call, for example, that would fail because that's not a valid CSS selector.
I suspect you're using some sort of library that does something like that; it might work in other browsers due to bugs in their CSS selector parsers or due to the library doing browser-sniffing and not running the same code in those other browsers.
精彩评论