I want to transfer the argument 7 from the html file
<button id="buttonseven" onclick="buttonClick(7)">7</button>
and how could I receive this argument in jQuery ?
$(document).ready(function(){
$('#buttonseven').click(function(){
})
})
I want to transfer the argument 7 from the html file
<button id="buttonseven" onclick="buttonClick(7)">7</button>
and how could I receive this argument in jQuery ?
$(document).ready(function(){
$('#buttonseven').click(function(){
})
})
2
Answers
you can save 7 in button attribute data-* form ,like code below:
so, from jQuery, you can do this:
you can read jquery data() function here
I used this post get the value of "onclick" with jQuery? to get the value of your onclick function and this post Get Substring between two characters using javascript to get the value between ( and ).
But the solution of user1702660 is more simple than this one i think 🙂