Reputation: 19
in my code i have around 11 image tags , all of them have an id of "#bigimage" i want to change the style of an image on each click on a specific button for the specific image meaning on the first click changing the #bigimage [0] second click changing the #bigimage [1] etc...
this is what i did:
<script>
//click event
$('.jssora05r').click(function() {
var abc=$('#bigimag').length;
var ind=0
$("#bigimag").index(ind).css("display", "block !important");
ind++;
});
</script>
it's not working, could someone help me?
Upvotes: 0
Views: 148
Reputation: 5075
just declare ind
out side of the click event
also you need to change that id selector to some class selector and add same class to all images
<script>
var int = 0;
//click event
$('.jssora05r').click(function() {
// change id to some class
var abc=$('.someclass').length;
$(".someclass").index(ind).css("display", "block !important");
ind++;
});
Upvotes: 1