Home  >  Article  >  Web Front-end  >  How to delete options in select in jquery

How to delete options in select in jquery

青灯夜游
青灯夜游Original
2020-12-21 17:39:273879browse

Deletion method: First use the jQuery selector to get the specified option (options element) that needs to be deleted from the select, and then use JQuery's remove() method to delete the option from the HTML document; the syntax "$( "option option").remove()".

How to delete options in select in jquery

The operating environment of this tutorial: windows7 system, jquery3.3.1 version. This method is suitable for all brands of computers.

Recommended tutorial: jquery video tutorial

If you want to use jQuery to remove options (options elements) from the select element, you can first use the jQuery selector to select the required ones from the select Delete the options element and then use JQuery's remove() method to remove the option from the HTML document.

Example:




		

单击按钮,从select选择框中删除选项



Rendering:

How to delete options in select in jquery

## The remove() method is used to remove selected elements, including All text and child nodes. This method also removes data and events from the selected element.

For more programming-related knowledge, please visit:

Programming Teaching! !

The above is the detailed content of How to delete options in select in jquery. For more information, please follow other related articles on the PHP Chinese website!

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