jQuery函数将下拉值从一个更改为另一个 [英] Jquery function changing the dropdown value from one to another

查看:98
本文介绍了jQuery函数将下拉值从一个更改为另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下拉列表值.如果我选择一个下拉列表(CandidateFunctions)值,它将填充另一个下拉列表(PreferredFunctions).这只是工作良好.但是当我第二次选择 CandidateFunctions 时,它并没有改变值.

I have dropdown values. if i select one dropdown(CandidateFunctions) values, it will populate the another dropdown(PreferredFunctions). This is working good only. but when i select the CandidateFunctions in the second time it is not changing the value..

我在jquery中的代码是

$(document).ready(function () {

                   $("#CandidateFunctions").change(function () {
                       if ($("#PreferredFunctions").val() == "" || $("#PreferredFunctions").val() == null) {
                           $("#PreferredFunctions").val($("#CandidateFunctions").val());
                       }
                   });
                });

即使第二次也要填充值?请帮助我...

how to populate the values even second time also? please help me...

推荐答案

像下面的代码应该可以帮助您:

Like The code below should help u:

$("#dropdwon1").change(function(){
    $("#dropdwon2").val($(this).val());
});

此处为

工作版本: http://jsfiddle.net/xkT3U/

这篇关于jQuery函数将下拉值从一个更改为另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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