Using jquery, How to redirect when changing a dropdown list?

I have a drop-down list if someone selects a parameter that I want to redirect to another page based on the selection.

How to do this using jquery?

+4
source share
2 answers

Bind the logic to the $.change() event and get the current value from $.val() to determine where the user should be redirected. This example assumes that the location is stored directly in the value itself.

 $(".mySelect").change(function(e){ window.location = $(this).val(); }); 
+20
source
 <select id="abc"> <option value="p1">Page 1</option> <option value="p2">Page 2</option> <option value="p3">Page 3</option> </select> $("#abc").change(function() { window.location.href = "http://domain/" + $(this).val() + ".html"; }); 
+8
source

Source: https://habr.com/ru/post/1303739/


All Articles