Home  >  Article  >  Web Front-end  >  Implementation code for assigning the selected value of DropDownlist to label based on Jquery_jquery

Implementation code for assigning the selected value of DropDownlist to label based on Jquery_jquery

WBOY
WBOYOriginal
2016-05-16 18:07:00863browse

jquery code

Copy code The code is as follows:

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

});

or
Copy the code The code is as follows:

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

Explanation of this:

var name = $("#DropDownList1 option:selected").val(); //Get the selected value in dropdownlist
var name1 = $("#DropDownList1").text(); //Get the value used in dropdownlist
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn