从选择下拉列表中选择项目时自动重定向 [英] Redirect automatically when selecting an item from a select drop-down list

查看:126
本文介绍了从选择下拉列表中选择项目时自动重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此页面按照我希望的方式进行操作: http://www.web-source .net / javascript_redirect_box.htm

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

但我想用jQuery找一个更好的方法,任何人都可以指向一个使用jQuery来完成此操作的好脚本?

But I want to find a better way using jQuery, can anyone point me to a good script that uses jQuery to accomplish this?

推荐答案

您不需要预先打包的脚本,只需几行代码即可。

You don't need a pre-packaged script for this, just a couple lines of code.

// get your select element and listen for a change event on it
$('#selectEl').change(function() {
  // set the window's location property to the value of the option the user has selected
  window.location = $(this).val();
});

这篇关于从选择下拉列表中选择项目时自动重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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