Huma Ali Huma Ali - 4 months ago 13
jQuery Question

Concatenating variable with jquery selector

I have a variable:

var MAX_OFFERS_TO_SHOW = 3;


And I want to use this variable as
index
for the jquery
:lt()
selector

$("div.notspecialoffer:lt()").slideDown();


How will I concatenate it?

Answer

Like this:

$("div.notspecialoffer:lt("+ MAX_OFFERS_TO_SHOW+")").slideDown();