[jQuery] Re: bug in id selector?
Backslash is the escape character for a JavaScript string, e.g. alert( 'a\'b' === "a'b" ); // true So when you use \. you're merely escaping the "." in the string - in other words the \ does nothing in this case. When you use \\ then the first \ escapes the second one and you get the \ in the string. Try these: alert( '#test2.3' ); #test2.3 alert( '#test2\.3' ); #test2.3 - same as above alert( '#test2\\.3' ); #test2\.3 - finally what you want -Mike > From: spinn...@vip.hr > > I believe that it will function as intended if you escape the > dot, like so: > $("#test2\.3") > > although I've tried now in Firebug and it seems you have to > escape the slash too, like so (don't know why, is it because > of Firebug, or?): > $("#test2\\.3")
[jQuery] Re: bug in id selector?
You have to use double slashes to escape it, that's right. It also works in CSS: $('#test2\\.3').hide() #test2\.3 { display:none } On Jan 22, 5:36 pm, spinn...@vip.hr wrote: > I believe that it will function as intended if you escape the dot, > like so: > $("#test2\.3") > > although I've tried now in Firebug and it seems you have to escape the > slash too, like so (don't know why, is it because of Firebug, or?): > $("#test2\\.3") > > Cheers, > Dennis. > > On Jan 22, 5:21 pm, "finn.herp...@marfinn-software.de" > > wrote: > > Sounds good. > > > Too bad my ids are given by an external xml-file. But since I wrote a > > workaround to replace all . in the ids with _ it's fine for me ;). > > > Thanks > > > Cheers > > > On Jan 22, 4:13 pm, Liam Potter wrote: > > > > jQuery will read it as id "test2" with the class "3" > > > > While periods are allowed in the attribute I would advise against them, > > > as it's not just jQuery that could struggle with them but most CSS as > > > well, as #test2.3 with again read as id "test2" with the class "3". > > > > Finn Herpich wrote: > > > > Hi everyone, > > > > > the attached example-code shows a problem I encountered today (firebug > > > > needed). > > > > > If an id-attribute contains dots, like > > > > > > > > jQuery isn't able to find it. > > > > If the dots are replaced by underscores everything works fine. > > > > > Afaik there is no limitation for the id which prohibit dots as a used > > > > symbol, so I guess this is a bug or for some reason not wanted? > > > > > Cheers
[jQuery] Re: bug in id selector?
I believe that it will function as intended if you escape the dot, like so: $("#test2\.3") although I've tried now in Firebug and it seems you have to escape the slash too, like so (don't know why, is it because of Firebug, or?): $("#test2\\.3") Cheers, Dennis. On Jan 22, 5:21 pm, "finn.herp...@marfinn-software.de" wrote: > Sounds good. > > Too bad my ids are given by an external xml-file. But since I wrote a > workaround to replace all . in the ids with _ it's fine for me ;). > > Thanks > > Cheers > > On Jan 22, 4:13 pm, Liam Potter wrote: > > > jQuery will read it as id "test2" with the class "3" > > > While periods are allowed in the attribute I would advise against them, > > as it's not just jQuery that could struggle with them but most CSS as > > well, as #test2.3 with again read as id "test2" with the class "3". > > > Finn Herpich wrote: > > > Hi everyone, > > > > the attached example-code shows a problem I encountered today (firebug > > > needed). > > > > If an id-attribute contains dots, like > > > > > > jQuery isn't able to find it. > > > If the dots are replaced by underscores everything works fine. > > > > Afaik there is no limitation for the id which prohibit dots as a used > > > symbol, so I guess this is a bug or for some reason not wanted? > > > > Cheers
[jQuery] Re: bug in id selector?
Sounds good. Too bad my ids are given by an external xml-file. But since I wrote a workaround to replace all . in the ids with _ it's fine for me ;). Thanks Cheers On Jan 22, 4:13 pm, Liam Potter wrote: > jQuery will read it as id "test2" with the class "3" > > While periods are allowed in the attribute I would advise against them, > as it's not just jQuery that could struggle with them but most CSS as > well, as #test2.3 with again read as id "test2" with the class "3". > > > > Finn Herpich wrote: > > Hi everyone, > > > the attached example-code shows a problem I encountered today (firebug > > needed). > > > If an id-attribute contains dots, like > > > > jQuery isn't able to find it. > > If the dots are replaced by underscores everything works fine. > > > Afaik there is no limitation for the id which prohibit dots as a used > > symbol, so I guess this is a bug or for some reason not wanted? > > > Cheers
[jQuery] Re: bug in id selector?
jQuery will read it as id "test2" with the class "3" While periods are allowed in the attribute I would advise against them, as it's not just jQuery that could struggle with them but most CSS as well, as #test2.3 with again read as id "test2" with the class "3". Finn Herpich wrote: Hi everyone, the attached example-code shows a problem I encountered today (firebug needed). If an id-attribute contains dots, like jQuery isn't able to find it. If the dots are replaced by underscores everything works fine. Afaik there is no limitation for the id which prohibit dots as a used symbol, so I guess this is a bug or for some reason not wanted? Cheers