this.hasClass is not a function

APD Toronto
APD Toronto used Ask the Experts™
on
Hi Experts,

I have the following code
$(document).ready(function(){

    //expand/collapse detail data
    $('.spMobile').on('click', function(){
        var expand = this.hasClass('fa-caret-right');
    });

});//document ready

Open in new window


With which I am trying to determine if the cliked element has the class fa-caret-right, but I am getting the following error

VM3768 functions.js:6 Uncaught TypeError: this.hasClass is not a function
    at HTMLSpanElement.<anonymous> (VM3768 functions.js:6)
    at HTMLSpanElement.dispatch (jquery-3.2.1.js:5206)
    at HTMLSpanElement.elemData.handle (jquery-3.2.1.js:5014)

Open in new window


Any help will be greatly appreciated.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
can you try:
var expand = $(this).hasClass('fa-caret-right');

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial