How to: Remove Options from One Select Box and retain One Option.

How to – One can easily remove options of a select box from HTML and append it to another selected by making use of simple jQuery functions such as append(), remove(). Nevertheless, when dealing with Select Element one important thing you should bear in mind is that though modifying the select element is not different from other DOM elements but some basic things should be kept in mind such as not to use the DOM directly but rather create HTML strings instead.

With jQuery remove() and append() methods for select elements, what was once a headache in the park has become a walk in the park.


$('#selectBox').find('option').remove()
.end().append('text')
.val('any');

Recently Published

»

Is Your Business Site Fully Accessible?

Does your business site have full accessibility? Even with the ADA ...

»

Secure Web: 5 Best Practices For Application Development

There are several essential best practices for secure web ...

»

Laravel PHP Framework: Features and benefits for web development

Companies and organizations are focusing on developing custom web ...

»

Web Development Vs. Software Development: What Is the Difference?

As technology continues to transform all aspects of our lives, a lot ...

»

Web Redesign : Is Your Landing Page Begging for one?

How do you know when it’s time to web redesign your landing page? ...

»

Customer Acquisition: Few Steps To Improve This.

Customer acquisition is essential to any business’s success — to ...

»

Mobile App Development Tools: 5 Enterprise-Ready For Rapid Deployment

There are several enterprise-ready mobile app development tools for ...

»

Docker: How To Build Better Development Security With It

The top concern among developers and DevOps teams is security within ...

»

Mobile Development: How to Reduce Costs

Modern markets have become so competitive that it has become vital ...