Home > Web Front-end > JS Tutorial > jquery dynamically add option example_jquery

jquery dynamically add option example_jquery

WBOY
Release: 2016-05-16 17:06:00
Original
1352 people have browsed it

jquery dynamically adds option

js dynamically add option

Copy code The code is as follows:

var sel= document.getElementById("Selected1");
sel.options.add(new Option("Please select",""));
sel.options.add(new Option("name","id"));

jquery dynamically adds option

Copy code The code is as follows:

$("#selectId").append("< ;option value='" value "'>" text "");

jquery removes all options

Copy code The code is as follows:

$("#selectedId option").remove() ;
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