javascript - how to get value of a button other than using 'by id' convention? -
how can value of button when clicked? know id in code below. there other method?
<button type="buton" id="a" value="<?php echo $re[0]; ?>" class="btn btn-primary" onclick="showalert()">start</button> <script type="text/javascript"> function showalert(){ var sub = document.getelementbyid("a").value; alert(sub); } </script>
<button type="buton" id="a" value="<?php echo $re[0]; ?>" class="btn btn-primary" onclick="showalert(this)">start</button> <script type="text/javascript"> function showalert(obj){ alert(obj.value); } </script>
Comments
Post a Comment