Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 0.54 KB  |  hits: 275  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. jQuery-Select list option hover
  2. $("select > option").hover(function ()
  3.     {
  4.         alert($(this).attr("id"));
  5.     });
  6.        
  7. $("select").hover(function (e)
  8. {
  9.      var $target = $(e.target);
  10.      if($target.is('option')){
  11.          alert($target.attr("id"));//Will alert id if it has id attribute
  12.          alert($target.text());//Will alert the text of the option
  13.          alert($target.val());//Will alert the value of the option
  14.      }
  15. });
  16.        
  17. alert($(this).text()); // will alert option text
  18.  
  19. alert($(this).val()); // will alert option value