javascript - 从选择下拉列表中选择项目时自动重定向

标签 javascript jquery html

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

但我想找到一种使用 jQuery 的更好方法,谁能告诉我一个使用 jQuery 来完成此任务的好脚本?

最佳答案

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

// 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();
});

关于javascript - 从选择下拉列表中选择项目时自动重定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/580281/

相关文章:

javascript - AngularJS:ng-keypress 不工作

javascript - 在每个列表中向下滑动

javascript - jquery 防止表单传输不起作用

javascript - 如何向 url 添加选项值

javascript - setInterval() 数据库检查的替代方案 -> Meteor.js

c# - 是否可以取消选择 RadioButton 组中的所有值?

html - 绝对定位的元素在动画完成后移动

html - 是什么导致了这个随机空白?

javascript - 慢弹跳Javascript

javascript - Bootstrap : Carousel not working