Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery: if class exists

Tags:

jquery

find

class

I want something that finds instantly on the page a class called prop and set it to hidden soon as there is one.

IMPORTANT: soon as a new element is added I want that element with prop class changed. Like a while loop

if( class='prop' == found ){

     set class to ('hidden');

}

And yes this function is inserted after the element caller. but it seems like it takes some time till the element is generated so I need a check on the class to remove it as fast as possible. I cant use a delay in this case have tried that with bad results.

like image 308
account28356723678 Avatar asked Jul 19 '26 21:07

account28356723678


1 Answers

You need hasClass function

if($('selector').hasClass('prop'))
    {
        $(this).removeClass("prop");
        $(this).addClass("hidden");
    }

This might help

like image 77
Rupesh Pawar Avatar answered Jul 22 '26 14:07

Rupesh Pawar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!