首页 > 编程 > JavaScript > 正文

基于Jquery的将DropDownlist的选中值赋给label的实现代码

2019-11-20 23:49:40
字体:
来源:转载
供稿:网友
jquery代码
复制代码 代码如下:

$(function() {
$("#DropDownList1").bind("change", function() {
$("#Label1").text($("#DropDownList1 option:selected").text());

});

或者
复制代码 代码如下:

$("#DropDownList1").bind("change", function() {
$("#Label1").text($("#DropDownList1").val());
});

其中对这个解释下:

var name = $("#DropDownList1 option:selected").val(); //获取dropdownlist 里面选中的值
var name1 = $("#DropDownList1").text(); //获取dropdownlist 里面所用的值
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表