The value principle and code of jquery mobile listbox_jquery
WBOY
Release: 2016-05-16 17:34:45
Original
1318 people have browsed it
The principle of jQuery operating listbox is not difficult, which is to move the selected items in the listbox to achieve the movement effect we need. In the example, I used the json data structure to dynamically bind the listbox, so that I can also become familiar with the use of json.
Let’s look at simple html first. Because server controls will be automatically converted to html tags, in the example, I did not use server controls. As follows: will be automatically converted into: html code is as follows:
//bind data var vlist = "" ; //Traverse json data jQuery.each(vData.datalist, function(i, n) { vlist = ""; }); //Bind data to listLeft $("#listLeft").append(vlist); //left move $ ("#btnRight").click(function() { //The data set selected by the data option is assigned to the variable vSelect var vSelect = $("#listLeft option:selected"); // Clone data is added to listRight vSelect.clone().appendTo("#listRight"); //Also remove the option in listRight vSelect.remove(); }); //right move $("#btnLeft").click(function() { var vSelect = $("#listRight option:selected"); vSelect.clone(). appendTo("#listLeft"); vSelect.remove(); });
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