Reputation: 2070
I have a select with id: param0.typeParameter.
I try to get it with jquery with:
$('#param0.typeParameter');
i get nothing but if it use this
document.getElementById('param0.typeParameter');
that work
Upvotes: 4
Views: 163
Reputation: 145398
To make jQuery select element with ID param0.typeParameter
instead of element with ID param0
and class name typeParameter
you should use the following:
$('#param0\\.typeParameter');
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 withid="foo.bar"
, can use the selector$("#foo\\.bar")
.
SOURCE: http://api.jquery.com/category/selectors/
DEMO: http://jsfiddle.net/LtRxg/
Upvotes: 14
Reputation: 3933
You can try this instead:
$('[id="param0.typeParameter"]');
Or else the code assumes you want to select an element with id param0
and class typeParameter
Upvotes: 10
Reputation: 57719
jQuery uses the CSS-selector language. Which causes "#param0.typeParameter"
to be interpretted as an element with id param0
and class typeParameter
.
The jQuery statement is more similar to:
document.querySelector("#param0.typeParameter");
Upvotes: 5