top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

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

+5 votes
74 views
What is wrong with this code line "$('#myid.3').text('blah blah!!!');"
posted Jul 14, 2015 by Shivaranjini

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

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

answer Jul 21, 2015 by Karthick.c
...