Let say
<div id = "test_id" class = "test_class"> </div>
JS
alert( $("#test_id").hasClass('test_class') ); // result is true
I just write another way to get the same expected result but didn’t work, Why?
var test = ' " ' + "test_id" + ' " ' ;
alert( $(test).hasClass('test_class') ); // not working, why ?????
The variable ‘test’ needs to be in the format of an ID selector – i.e.
#testSo it should be: