Avatar of APD Toronto
APD Toronto
Flag for Canada

asked on 

this.hasClass is not a function

Hi Experts,

I have the following code

    //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.

Avatar of undefined
Last Comment
Flabio Gates

8/22/2022 - Mon