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

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -