aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes JQuery Element ID Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "JQuery Element ID Question" Watch "JQuery Element ID Question" New topic
Author

JQuery Element ID Question

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

The majority of the elements in my pages have id's like

foo.hoo

However, JQuery tends to not like this with respect to

$('#foo.hoo')

It doesn't error out, it just doesn't grab the element. Is there anyway around this?


GenRocket - Experts at Building Test Data
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

jQuery is following CSS which doesn't allow for dots in id names. It kinda sucks cause I like using dots for name-spacing ids, but that precludes their use in CSS and jQuery.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

Originally posted by Bear Bibeault:
jQuery is following CSS which doesn't allow for dots in id names. It kinda sucks cause I like using dots for name-spacing ids, but that precludes their use in CSS and jQuery.


Yea, I just searched the JQuery mailing list and discovered the same thing. Thanks.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61434
    
  67

You can escape the dot, but it's pretty ugly:

Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Yes, basically the dot is used to denote a CSS class name in a selector. The only way around is to do how Bear proposes, i.e. to escape the dot.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15299
    
    6

It's a big ugly but its not too bad and it's less intrusive than the work around. Thanks.
 
wood burning stoves
 
subject: JQuery Element ID Question