I've looked at other questions, but none of them have really helped me. I want to give IDs to a number of elements belonging to the same class without manually doing it. Here is my code that isn't working:
$curelem = $(".item:first");
for (var $i=0; i < $(".item").length; ++$i){
$curelem.attr("id", "item" + $i);
$curelem = $curelem.next('a');
}
Is it some small syntax error, or am I going about it entirely wrong?
as? Why not use an explicit binding in your code? Alternatively, a worse but simpler and still better solution, you can store adata-urlattribute on youratags that contains a selector for thedivelements you want to open.