JQUERY
When I clicked the both 2 buttons it only returns the value 1
$(document).ready(function() {
var getvalue = $(".view_btn").val();
$(".view_btn").click(function() {
alert(getvalue);
});
});
PHP
<?php foreach ($studentRankingViewGET as $studentRankingViewSHOW) {?>
<input type="button" value="<?php echo $studentRankingViewSHOW['id'];?>" class="view_btn">
<?php } ?>
This returned 2 values .i.e. 1 AND 2
.btnelement? and also make it readable..val()will always return value of first element from matched elements. So either iterate them using.each()or use DOM relationship to target them