how to set a variable on a jquery filter?

how to set a variable on a jquery filter? This is not working.

var setHighLight = "last";

$("#ul_b li:(' + setHighLight +')").addClass('highlight');
areyouready344Asked:
Who is Participating?
 
leakim971Connect With a Mentor PluritechnicianCommented:
correction : $("#ul_b li:" + setHighLight).addClass('highlight');
0
 
leakim971PluritechnicianCommented:
$("#ul_b li:' + setHighLight).addClass('highlight');
0
 
areyouready344Author Commented:
thanks Leakim, its now working.
0
 
leakim971PluritechnicianCommented:
var third = 2;
$("#ul_b li:eq(" + third + ")").addClass('highlight');
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.