var i = 1;
$('select').on("change", i, function () {
alert(i);
});
This is not doing anything and I am unsure why…
var i = 1;
$('select').change(function (i) {
alert(i);
});
This is returning [object Object]
Anyway I would like to be able to pass an int to the change method and cannot see what I am doing wrong.
The parameter in the function in the event is not one you pass, it’s the event object, and it’s passed by jQuery when the event is ran.
You can pass a value to
.on, and its value will appear inevent.data.Example:
Or since you are declaring
ioutside the function, you can just use it inside.