Win a copy of AWS Security this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

JQuery Element ID Question

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Sheriff
Posts: 67405
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 67405
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can escape the dot, but it's pretty ugly:

 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a big ugly but its not too bad and it's less intrusive than the work around. Thanks.
 
My previous laptop never exploded like that. Read this tiny ad while I sweep up the shards.
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic