I want to send multiple data from on click function to jquery function like this code.
When I click on my button I get [object Object]undefined] in alert box
Code :
$(function() {
$("#button").click(function myf(data1, data2) {
alert(data1 + data2);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<a href="#" id="button" onclick="myf('hello','word');">click</a>
How can I do it?
.click()and the other usingonclickattribute!id. Theidmust be unique, so you might as well code the data into the function.