Hitesh Chauhan Hitesh Chauhan - 3 months ago 22
HTML Question

Is it possible to get onclick value by input name in jQuery

Is it possible to get on click value by input name in jQuery? I don't have neither class nor id and I want to get the on click value on name only. Please help me out. As I am doing all this in a software to get data.

<input type="button" name="view" value="Click To View Phone, Mobile &amp; Fax Numbers" onclick="viewphone(71241,'divid71241')">

Answer

try this , it is easy to get onclick value

<html>
<head></head>
<title></title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<body>


<input type="button" name="view" value="Click To View Phone, Mobile &amp; Fax Numbers" onclick="viewphone(71241,'divid71241')" style="border: 0px;">

</body>

<script type="text/javascript">
    
   $(document).ready(function(){
   	$('[name=view]').click(function(){
   		var valueis = $(this).attr('onclick');
   		alert(valueis);
   	});
   });


</script>

</html>