Home › Forums › JavaScript › Question about jQuery .hasClass() › Reply To: Question about jQuery .hasClass()
September 29, 2013 at 8:21 pm
#151659
Member
Really difficult to say without fully knowing what the code is trying to accomplish.
For starters, I’d be storing $(this)
as a variable just inside the click function like this:
var button = $(this);
…and then going:
button.hasClass('whatever')
Depending on what you’re trying to do you might want to look into using a switch
: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/switch