I have a page in which buttons are dynamically generated by PHP based on a MySQL table. Each button is inside an anchor tag. When the anchor tag is clicked, it calls a Javascript function which performs several operations.
For one of these operations, I need to get the value of the button and pass it as a parameter. AFAIK, I can't use an ID because the buttons are dynamically generated and there may be any number of them.
Here's the button/anchor code:
<a href="javascript:void(0)"onclick="updateDetails($(this).text(),$(this).closest('li').attr('id'),<SOMETHING HERE TO GET VALUE OF BUTTON>);"><button type="button" class="regbutton" value="'.$row['instance_id'].'">'.$row['DATE'].'</button></a></span>';
It seems that jQuery functions like .next()
only apply to sets of elements like li
as opposed to two dissimilar element types. Any ideas?