This works:
HTML:
<div id="mydiv">Help!</div>
CSS:
div {
background-color: red;
}
Jquery:
function myfunction( c1 ) {
$("#mydiv").css({'background-color': 'blue' });
}
$("#mydiv").on('click', myfunction );
I understand that using () immediately after a function calls that function.
So...
How can I bind a function to a click, and pass parameters at the same time?
HTML:
<div id="mydiv">Help!</div>
CSS:
div {
background-color: red;
}
Jquery:
function myfunction( c1 ) {
$("#mydiv").css({'background-color': c1 });
}
$("#mydiv").on('click', myfunction("blue") );