Heim  >  Artikel  >  Web-Frontend  >  基于Jquery的将DropDownlist的选中值赋给label的实现代码_jquery

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

WBOY
WBOYOriginal
2016-05-16 18:07:00864Durchsuche

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 里面所用的值
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn