使用jquery,如何重定向下拉列表选择更改? [英] using jquery, How to redirect when drop down list selection changes?

查看:88
本文介绍了使用jquery,如何重定向下拉列表选择更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个下拉列表,如果有人选择一个选项,我想根据选择重定向到另一个页面。

I have a drop down list, if someone selects an option I want to redirect to another page based on the selection.

我如何通过jquery来做到这一点?

How can I do this via jquery?

推荐答案

将逻辑绑定到 $。change()并从 $。val()获取当前值,以确定用户应该重定向到哪里。此示例假定一个位置直接存储在值本身中。

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

$(".mySelect").change(function(e){
  window.location = $(this).val();
});

这篇关于使用jquery,如何重定向下拉列表选择更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆