Find div by given class and data-id
I want to find div by given class and data-id but following line doesn't work (In this example class is lesson and data-id is variable)
$('div.lesson[data-id=' + htag + ']').addClass('underline');
What am I missing?
Update
Full function looks like that
LoadLessons(cid); LoadQuestions(lid); $('div.course[data-id=' + cid + ']').addClass('underline'); $('div.lesson[data-id=' + lid + ']').addClass('underline');
Load.. functions are ajax calls. And class must affect content which returned by ajax call. First addclass works but second not.
Answers
Try this,
$('div[class=lesson][data-id="' + htag + '"]').addClass('underline');