Reputation: 178
I am using following jquery selector by id
$("#rs_0.01").val();
So my small question is: this valid or not ? As it's not working in my case.
Upvotes: 1
Views: 351
Reputation: 115242
Check documentation of jQuery Selectors
To use any of the meta-characters ( such as !"#$%&'()*+,./:;<=>?@[]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \. For example, an element with id="foo.bar", can use the selector $("#foo\.bar"). The W3C CSS specification contains the complete set of rules regarding valid CSS selectors. Also useful is the blog entry by Mathias Bynens on CSS character escape sequences for identifiers.
$("#rs_0\\.01").val();
or use attribute equals selector instead
$("[id='rs_0.01']").val();
Upvotes: 4
Reputation: 391
In your case you got few ways to retrieve value of a textbox by using id selector with the same name which you have specified in the question..
One way is by doing like this:
$("[id='rs_0.01']").val();
or you can use the escape sequence inbetween the selector name like this:
$("#rs_0\\.01").val();
Upvotes: 0
Reputation: 8101
Use: You need to escape special chars:
$("#rs_0\\.01").val();
Upvotes: 0