I have an onclick function inside for loop in PHP. I want to show particular DIV when I click on particular onclick function.
These are my codes.
This is PHP code
for($i = 1; $i < 10; $i++)
{
echo '<a href onclick="get_number($i)">Get Number</a>';
echo '<div class="ans_option_box" style="display:none">show this div</div>';
echo '<br>';
}
This is jQuery code
<script>
function get_number(id)
{
$(this).find('.ans_option_box').show();
}
</script>
I really want, when I click on 5th onclick value. DIV should appear under 5th value. Thanks in advance!