Redirect automatically when selecting an item from a select drop-down list

后端 未结 5 1302
予麋鹿
予麋鹿 2020-11-29 05:26

This page does it the way I want it to: http://www.web-source.net/javascript_redirect_box.htm

But I want to find a better way using jQuery, can anyone point me to a

5条回答
  •  猫巷女王i
    2020-11-29 05:57

    using jQuery:

    $('#selectEl').bind("change keyup",function()
    {
      // set the window's location property to the 
      // value of the option the user has selected
      window.location = $(this).val();
    });
    

    works for usual changing of options and arrow keys.

    You might be able to use this extension: http://plugins.jquery.com/project/mousewheel Haven't tried it yet. :)

    There are also mouse options you can add to bind() there. Go to: api.jquery.com/category/events/mouse-events/ Any function there is a name() for on that page, you can use it's 'name' in bind() above. Just as I did with change()=>'change' and mouseup()=>'mouseup' - easy peasy :)

    • Peace!

提交回复
热议问题