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
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to