remove all options from select jquery

0
()

Today, We want to share with you remove all options from select jquery.In this post we will show you Removing an item from a select box using jQuery, hear for How to remove all options within a Html select box using JQuery? we will give you demo and example for implement.In this post, we will learn about JQuery Remove Combobox Items(Options) From DropDownList with an example.

how to add / remove dropdown dynamically with jquery?

here simple example for delete all the options of a select box and then add one option and select it with jQuery.

Read Also:  Simple DateTime range with two inputs Example

Example 1: index.html

<!DOCTYPE html>
<html lang="en">
 
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Welcome - www.pakainfo.com</title>
</head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
 
<body>
  <select id="demo">
    <option value="Mp3Goo">Mp3Goo</option>
    <option value="Khatrimaza">Khatrimaza</option>
  </select>
</body>
<script>
  $('#demo')
    .find('option')
    .remove()
    .end()
    .append('<option value="Tamilrokers">Tamilrokers</option>')
    .val('Tamilrokers')
    ;
</script>
 
</html>

Remove From Select Drop Down

Example 2:

$("#liveproduct option[value='option1']").remove();

Remove All Options Except The First

Example 3:

$('select').children('option:not(:first)').remove();

Free Live Chat for Any Issue
Download

I hope you get an idea about jquery remove all options from select except selected.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  JQuery Remove combobox items(options) from DropDownList

How useful was this post?

Click on a star to rate it!