CLiown
CLiown

Reputation: 13843

Run function IF :has :not class

I only want this function to run if .toolbar li does not have the class .Oactive:

$(".prod_description").mousedown(function(){
$(this).parent().parent().addClass('mousedown');
$(this).parent().parent().parent().addClass('mousedown'); 
})
.mouseup(function(){
$(this).parent().parent().removeClass('mousedown');
$(this).parent().parent().parent().removeClass('mousedown');
});

What do I need to wrap this in to ensure this?

something like: if $(.toolbar li):not(:has .Oactive) {

}

Upvotes: 2

Views: 3867

Answers (2)

Amy B
Amy B

Reputation: 17977

if ($('.toolbar li').hasClass('Oactive'))
{
    // do cool stuff
}

Upvotes: 2

Quasipickle
Quasipickle

Reputation: 4498

if($("ul.toolbar li:not(.oActive)")){

You should always specify the element type (ul in this case) when possible when using classes - it speeds up the selector engine.

Upvotes: 3

Related Questions