What is wrong with this code line "$('#myid.3').text('blah blah!!!');"



What is wrong with this code line "$('#myid.3').text('blah blah!!!');"..

Answer / chaitanya

The problem with above statement is that the selectors is having meta characters and 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").

So the correct syntax is,

Hide Copy Code

$('#myid\.3').text('blah blah!!!');

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More jQuery Interview Questions

Where jQuery code is getting executed?

0 Answers  


How do you select element by ID in jQuery?

1 Answers  


Explain .empty() vs .remove() vs .detach() in jquery

0 Answers  


How does jquery store data related to an element?

0 Answers  


What is the advantage of using the minified version of jquery rather than using the conventional one?

0 Answers  






What is get()? : jquery mobile

0 Answers  


Define type paremeter of jquery ajax method?

0 Answers  


What is the latest version of jquery?

0 Answers  


Tell me do I need to add the jquery file both at the master page and content page as well?

0 Answers  


Explain some of the key concepts of good code organization patterns.

0 Answers  


What is resize() function in jquery?

0 Answers  


Tell me how to use migrate jquery plugin if possible? : jquery mobile

0 Answers  


Categories