Sunday, 18 August 2013

How do I take in a event variable in Javascript / jQuery?

How do I take in a event variable in Javascript / jQuery?

This feels like a amateurish question, but how do you take in an event in
a custom function in Javascript / jQuery?
Right now I'm using this:
$(".button").on("click", function(event){
removeButton();
});
function removeButton() {
$(this).removeClass("specifiedClass");
}
I'm trying to make removeButton() understand that I want it to remove the
class that is on the .button itself.
I'm not sure how to make removeButton() take in the event, but I've tried:
$(".button").on("click", function(event){
removeButton(event);
});
function removeButton(event) {
$(this).removeClass("specifiedClass");
}
But its not working. Does anyone know how?

No comments:

Post a Comment