- 时间:2021-04-18 02:18 编辑: 来源: 阅读:
- 扫一扫,手机访问
摘要:基于Jquery的将DropDownlist的选中值赋给label的实现代码
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 里面所用的值