this.hasClass is not a function

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.
APD TorontoAsked:
Who is Participating?
 
Flabio GatesCommented:
can you try:
var expand = $(this).hasClass('fa-caret-right');

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.