javascript - Function that to look up then perform task -


i trying write short script looks see if class or id present in document. if following:

$(".tab_item").removeclass("tab_item_color"); $(this).addclass("tab_item_color"); 

you can use length property on jquery object. example:

if( $('.your-class').length ) {     $(".tab_item").removeclass("tab_item_color"); } 

the if() block execute if there element in dom has class of your-class.


Comments

Popular posts from this blog

many to many - Django Rest Framework ManyToMany filter multiple values -

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

Java Entity Manager - JSON reader was expecting a value but found 'db' -