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

How to add and remove css classes to an element using jquery?

0 Answers  


Which are the popular jQuery CDN? and what is the advantage of using CDN?

1 Answers  


What is difference between .setinterval() and .delay() ?

0 Answers  


Explain deferred and promise object in jquery? : jquery mobile

0 Answers  


How to use connect?

0 Answers  






Where can we download JQuery?

0 Answers  


Which command will give a version of jQuery?

0 Answers  


What are the fastest selectors in jQuery?

1 Answers  


What were the biggest challenges of getting the 1.7 release out there?

0 Answers  


Explain the difference between $(this) and 'this' in jquery?

0 Answers  


How do you stop the currently-running animation?

1 Answers  


What is each() function in jQuery? How do you use it?

0 Answers  


Categories