【发布时间】:2017-01-10 10:29:55
【问题描述】:
所以我希望我的页面在选择特定值时重定向到不同的页面。是否改变值。如果该值已经是其他值,则 on Change 可以正常工作,但如果该值已被选为重定向页面的值,则它不起作用
<script>
$("select").on('change', function() {
if ($(this).val() == 'option2') {
var data = $(this).attr("data_val");
var sid = $(this).parent().parent().children()[3];
var sid_value = $(sid).children()[0].value;
window.location = 'new.php?data=' + data + '&sid=' + sid_value;
}});
</script>
if the select is set to option1 and i select option2 from the dropdown then the page redirects but when the option2 is already selected in the select and i open the dropdown again & click on option2 it doesn't redirect, please help me实现这一目标。
【问题讨论】:
标签: javascript jquery select onchange url-redirection