How to create a quick jump menu with jQuery
Join the DZone community and get the full member experience.
Join For FreeHow to create a quick jump menu with jQuery This is part of my snippets library at https://github.com/lordspace/snippets/tree/master/js/quick_jump
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript" charset="utf-8"> //<![CDATA[ $(document).ready(function() { $('.site_quick_jump').change(function(){ // option 1 use a JS redirect in the current window //window.location.href = $(this).val(); // option 2; set the 'action' of the form and submit it if ($(this).val() != '') { $('#site_quick_jump_form').attr('action', $(this).val()); // $('#site_quick_jump_form').attr('target', '_blank'); // new window $('#site_quick_jump_form').submit(); // Go! } }); }); // doc ready //]]> </script> <div class="site_quick_jump_container"> <form id="site_quick_jump_form" method="get" action=""> Go to: <select class="site_quick_jump"> <option></option> <option value="http://yahoo.com">Yahoo!</option> <option value="/product1.html">Product 1</option> <option value="/product2.html">Product 2</option> </select> </form> </div>
From http://www.devcha.com/2011/08/how-to-create-quick-jump-menu-with.html
Opinions expressed by DZone contributors are their own.
Comments