I've written a code in jQuery as follows
$(document).ready(function() {
$("li").click(function() {
var str = $(this).index();
alert(str);
$("#headdiv div:nth-child(" + str + ")").addClass("product-active");
});
});
I want to pass the value stored in the str variable as a nth child index number. Where i'm doing wrong?