How to use foreach loop in jquery?
How to loop in jquery? I am having 1 issue like:
var current = 0;
jQuery(".bod-item").each(function() {
alert("#pi-"+current);
jQuery("#pi-"+current).click(function(){
alert("#mob-"+current);
jQuery("#mob-"+current).slideToggle("slow");
});
});
current++;
Now what I want is I have 3 `bod-item`
Each bod item has its separate id like:
bod-item #pi-0
bod-item #pi-1
bod-item #pi-2
When #pi-0 gets clicked, #mob-0 should toggle.
Similarly, When #pi-1 gets clicked, #mob-1 should toggle.
and so on...
Can;t figure out as how to loop inside Jquery. Please help.