CodeyMonkey
CodeyMonkey

Reputation: 739

jQuery - Exclude an li from this function?

I have a ul list of 8 li's on the last li it has the id #search - I don't want the dropdown applid to this, how can I exclude it? here's my code..

$(document).ready(function () {     
  $('#navigation li').hover(function () {
    // Show the sub menu
    $('ul', this).stop(true,true).slideDown(300);
  },
  function () {
  //hide its submenu
   $('ul', this).stop(true,true).slideUp(200);         
  });
});

Thanks

Upvotes: 2

Views: 55

Answers (1)

Starx
Starx

Reputation: 79021

Use jQuery's .not()

$('#navigation li').not("#search").hover(function () {
   // Show the sub menu
   $('ul', this).stop(true,true).slideDown(300);
},
function () {
  //hide its submenu
  $('ul', this).stop(true,true).slideUp(200);         
});

Upvotes: 5

Related Questions