Saturday, 24 August 2013

Previous Interview Question Next Interview Question
Home

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

 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,
$('#myid\\.3').text('blah blah!!!');

Previous Interview Question Next Interview Question
Home

0 comments :

Post a Comment