Hehe - it seems like we have discussion about once a month - it goes
something like this:
You: "I use IDs with '.' and/or ':' in them - it's part of the (X)HTML spec!"
Me: "Ooh, that'd be nice - but it''s actually not of the CSS Selector
spec, which jQuery uses."
When we get an FAQ up, I'll be sure to add it. No worries, though.
Think about it in this sense - is it possible to use these as
selectors - and what exactly do they mean?
#foo.bar
#foo.bar3
#foo.3
#foo:bar
#foo:link
#foo:visited
Both ':' and '.' have special meaning in CSS and/or XPath, so it's
really best to use another character if you wish to access/style them
using jQuery/CSS.
--John
On 8/19/06, John Beppu <[EMAIL PROTECTED]> wrote:
> I was playing around with jQuery today, and I came across something
> unfortunate.
>
> I was in the habit of using the "." character in id attributes. For
> example, if I had a page full of notes, the mark-up might look like:
>
> <div class="note" id="note.3">3rd note</div>
> <div class="note" id="note.4">4th note</div>
>
> What's unfortunate is that:
>
> $('#note.3').size() == 0
> $('note.3').size() == 0
>
> The lesson here might be that even though "." is a legal character[1]
> to have in an id field, its existence in an id can conflict with CSS
> selectors that interpret "." as a sigil to signify that a class name
> follows. This really sucked, because I used the "." character in id
> attributes extensively (until now).
>
> I hope that I can switch over to using ":" as a separator character to
> use in my id attributes. I also hope that it doesn't conflict with
> CSS selectors or XPath, but I'm not sure on either count.
>
> [1] http://www.w3.org/TR/xhtml1/#C_8
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
--
John Resig
http://ejohn.org/
[EMAIL PROTECTED]
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/