Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select elements with periods in ID using jQuery?

I have an id with a dot ('.') . I am not able to select it using jQuery.

For example:

 <p id="sec.ond">this is another  paragraph</p>

How can I use such an id to select this element?

I get such ids while I use spring forms with arrays, e.g.:

<form:input path="abc[0].firstName" />

This will result in:

<form:input id="abc0.firstName" name="abc[0].firstName" />

Thanks in advance for any help.

like image 323
Vamshi Avatar asked Jun 17 '11 13:06

Vamshi


1 Answers

You can escape it to select it in jQuery.

Example:

$('#sec\\.ond').doSomething()

Fiddle: http://jsfiddle.net/maniator/C7qhF/
See Also: How do I get jQuery to select elements with a . (period) in their ID?

like image 88
Naftali Avatar answered Sep 28 '22 05:09

Naftali