I'm sorry if this is a stupid question, but I really don't know :(
Consider the code below:
function myTogglerFunc() {
$("h1").toggleClass("fave");
}
$(function () {
$("#button").click(myTogglerFunc);
})
This does what I want it to do pretty easily. Notice the first function is a simple Javascript function, but the second one is a jQuery function because it is within $().
But I thought, hm, the second function doesn't need to be a jQuery function. It can just be a regular Javascript function like the first one, and I changed my code to:
function myTogglerFunc() {
$("h1").toggleClass("fave");
}
function () {
$("#button").click(myTogglerFunc);
}
and I got an error message.
I really don't know why this is wrong. If anyone can explain, please do. Thank you!