I have a foreach loop in php like below.
<?php
$i = 0;
foreach ($query as $value) { ?>
<button id="show[<?php echo $i;?>]" class="btn btn-success" type="button">View</button>
<div id="blah[<?php echo $i;?>]">Joel</div>
<?php
$i++
} ?>
Now this loop work fine and I am getting id for each buttons and divs with unique id. But I want to add a jquery click function like below.
$("#show").click(function(){
$("blah").hide();
});
But since it is inside a loop and have different id's with them how to add this jquery function for each buttons?
onclickto the html elementclassinstrad ofidand then usingthison the jQuery code.