I'm using jQuery to activate a function every time the user clicks on a button that has a certain class. I'm trying to get the value of the button clicked, and so far, failing.
window.onload = function() {
$('.button').click(function(item) {
console.log(item.value);
});
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<button class="button" value="7">7</button>
The expected result would be "7", since that is the value of the button. Currently, I'm getting undefined.
Thanks in advance!