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

Explain the difference between body onload() and document.ready() function? : jquery mobile

0 Answers  


Tell me does jquery 2.0 supports ie? : jquery mobile

0 Answers  


How to revert the most recent ‘destructive’ operation, changing the set of matched elements to its previous state using ?

0 Answers  


And finally, if you could give one tip to any new budding jquery ui developers, what would it be?

0 Answers  


What is the goal of cdn and what are the advantages of using cdn?

0 Answers  






Differentiate among .empty() vs .remove() vs .detach() in jquery.

0 Answers  


Which operating system is more compatible with jQuery?

0 Answers  


Explain slidetoggle() effect.

0 Answers  


How to select combobox select value and text using jquery?

0 Answers  


How can related code be encapsulated? Give example.

0 Answers  


What methods used to provide effects?

0 Answers  


How to get attributes of an element using jQuery?

0 Answers  


Categories