Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 18:07:00
Original
889 people have browsed it

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
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template