david david - 1 year ago 71
jQuery Question

Function that to look up then perform task

I am trying to write a short script that looks to see if a class or id is present in then document. If it is then do the following:


Answer Source

You can also do this

First Way

$(function() { 
    if ($('.yourClassName').length){
        $(".tab_item").removeClass("tab_item_color").addClass("YourNewClassName"); //It will swap your class.                          

For more information you can also visit .length

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download