I have a problem that i cannot get a class from a variable in javascript.
var li_id = LI_element.id;
if(!($("'#"+li_id+"'").hasClass("abc"))) {
console.log(LI_element);
}
Here, li_id gives me id of an element and i want to check that this element has the class abc or not. But, when i execute the above command it gives me error that says
throw new Error( "Syntax error, unrecognized expression: " + msg );
I assume there is some error in the if statement. Thanks for your help!
msgof the error? Also you can simply use$(LI_element).hasClass(...instead of concatenating a selector together.