Jquery Syntax Error, Unrecognised Expression
syntax error, unrecognised expression: #2015-11-30|1112|1 I have an anchor tag with an Id of '2015-11-30|1112|1' that I would like to apply a class to. I am doing the same method
Solution 1:
You should escape the special chracters in your id
using \\
, check example bellow.
Hope this helps.
console.log( $("#2015-11-30\\|1112\\|1").text() );
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divid="2015-11-30|1112|1">Div text example</div>
Solution 2:
For your current code to work, you don't have to use that id selector since you already have the reference of the object inside the event function.
$(document).ready(function() {
$("#tbl_calendar").on("click", "a", clickAppointment);
functionclickAppointment(eventData) {
//"this" will have a reference to the clicked object
$(this).addClass("selected");
}
});
Not sure about your HTML, but considering something similar to the below one.
<ulid="tbl_calendar"><li><aid="2015-11-30|1112|1">Click</a></li></ul>
Post a Comment for "Jquery Syntax Error, Unrecognised Expression"