in Advanced 

Resource preview: Know-how

HomeResource preview:
Log in

Selecting elements without specific class in jQuery

If you want to select all same level elements without the ones with specific class in jQuery you can do the following:



$(".tab li[class!=selected]").hover(
    function () {
      $(this).addClass("selected");
    },
    function () {
       $(this).removeClass("selected");
    }
 );


or

 $(".tab li:not(.selected)").hover(
    function () {
      $(this).addClass("selected");
    },
    function () {
       $(this).removeClass("selected");
    }
 );


In the examples above we were assigning class 'selected' to all tabs that were not already selected( elements that not has the class .selected)

Vote:
Comments: 0
Please vote! Your opinion matters!
If you want to share knowledge with the others, post a resource
Add resource
| Home | Hall of fame | Registration | Log in | Terms of service | Privacy policy | Help | Contacts | RSS |