Getting Uncaught Error: Syntax Error, Unrecognized Expression
Solution 1:
This is happening because u1@g.com
is not a valid value for an element's ID, so jQuery is unable to parse your selector.
From the HTML4 spec:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
The solution is to use a valid value for your ID.
Re: your comment below, you are getting undefined
because you are using closest()
wrong (please follow that link to find out what closest()
actually does).
I'm willing to bet that you have the id
Contact_LastName
in multiple places in your page, and that is a big problem because ids have to be unique.
I am also very curious why you are selecting the row
div and retrieving its ID, just so that you can use that ID to re-select it in the next line.
Instead of your current approach, get rid of your duplicate IDs and use this:
$('.btn-success').off('click').on('click', function (e) {
e.preventDefault();
var row = $(this).closest(".row");
var lnameval = row.find("input[name='ContactLastName']").val();
alert(lnameval);
});
Solution 2:
The error is coming from Sizzle, which is used by jQuery to parse the element selector.
Your div has a strange id: u1@g.com
. Try using ids without @
.
Post a Comment for "Getting Uncaught Error: Syntax Error, Unrecognized Expression"