基于Jquery的將DropDownlist的選中值賦給label的實現(xiàn)代碼
更新時間:2011年05月06日 14:43:52 作者:
使用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 里面所用的值
復(fù)制代碼 代碼如下:
$(function() {
$("#DropDownList1").bind("change", function() {
$("#Label1").text($("#DropDownList1 option:selected").text());
});
或者
復(fù)制代碼 代碼如下:
$("#DropDownList1").bind("change", function() {
$("#Label1").text($("#DropDownList1").val());
});
其中對這個解釋下:
var name = $("#DropDownList1 option:selected").val(); //獲取dropdownlist 里面選中的值
var name1 = $("#DropDownList1").text(); //獲取dropdownlist 里面所用的值
相關(guān)文章
jQuery中調(diào)用WebService方法小結(jié)
以前在寫ajax請求時,總是喜歡使用jQuery+ashx的方式進行調(diào)用,今天采取jQuery+WebService的方法來做ajax請求,發(fā)現(xiàn)這種方式比使用ashx的方式要更方便。2011-03-03