Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

different result with jquery and javascript

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

like image 250
redfox26 Avatar asked Nov 28 '22 11:11

redfox26


1 Answers

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');

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 with id="foo.bar", can use the selector $("#foo\\.bar").

SOURCE: http://api.jquery.com/category/selectors/

DEMO: http://jsfiddle.net/LtRxg/

like image 86
VisioN Avatar answered Dec 09 '22 18:12

VisioN