jQuery-Select list option hover

前端 未结 3 1708
旧巷少年郎
旧巷少年郎 2020-12-02 01:48

I want to alert an option when the mouse-cursor is over it. I use this code:

$(\"select > option\").hover(function ()
    { 
        alert($(this).attr(\"         


        
3条回答
  •  借酒劲吻你
    2020-12-02 02:20

    If you make a "listbox" type select box by adding a "size=x" attribute like this:

    
    

    The hover event will work on the option elements:

    $('option').hover(function(){
         //code here
    });
    

提交回复
热议问题