Forum Moderators: open
$(element)
.mouseover(function() {
console.log('a')
})
.mouseout(console.log('b'))
.click(console.log('c'));
$(element)
function outputA() {
console.log('a')
}
function outputB() {
console.log('b')
}
$(element)
.mouseover(outputA)
.mouseout(outputB)
.click(() => console.log('c'));
you're executing console.log('b'), and then passing the return value of that (undefined) to mouseout
Note, the function you pass in doesn't need to be nameless.
So it only returns the return value of what was ran, instead of actually running it?
console.log is a named function
Note, the function you pass in doesn't need to be nameless.
function buttonClick() {
console.log('made it to .button click');
}
$('.button').click(buttonClick()); Or would I have to use the lengthier $('.button').click((e) => buttonClick(e));?
$('.button')
.click({ name: "foo" }, buttonClick);
function buttonClick(bar) {
console.log('the param is ' + bar.data.name);
} $('.button').click(e, buttonClick);
$('.button').click((e), buttonClick);
$('.button').click({ event: e }, buttonClick);