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?


Full function looks like that

        $('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.


Try this,

Live Demo

$('div[class=lesson][data-id="' + htag + '"]').addClass('underline');

Need Your Help

Is Task.Run or Task.Factory.StartNew are bad practice for windows phone or any other client platform?

c# .net windows-runtime windows-phone async-await

I have WP 8.1 app that using web service a lot, and I want to keep it as much responsive as possible. From iOS dev expierense - there is one strict rule: "Do not do in UI thread any complex calcula...

Find indices of a list of values in a numpy array


I have a numpy master array. Given another array of search values, with repeating elements, I want to produce the indices of these search values in the master array.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.