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
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
Share Improve this question asked Nov 19, 2013 at 17:04 redfox26redfox26 2,0704 gold badges25 silver badges33 bronze badges 4- typeParameter is supposed to be a css class ? – poudigne Commented Nov 19, 2013 at 17:06
- whats the difference? Maybe the ».« is no good idea… – philipp Commented Nov 19, 2013 at 17:06
-
1
You should just avoid using dot in your
id
name. Dot are used to define a class – poudigne Commented Nov 19, 2013 at 17:10 - It's the spring way to manage a class with many field – redfox26 Commented Nov 19, 2013 at 17:11
3 Answers
Reset to default 14To 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');
Official Proof
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./category/selectors/
DEMO: http://jsfiddle/LtRxg/
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
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");