Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

254
Views
How to clear all selected items in a SELECT input using jQuery?

I am think this should be fairly easy, but struggling a bit ... I have a SELECT input element that allows the user to select multiple items. I would like to provide a mechanism for them to clear all selected items, probably will just be a SPAN tag or something similar.

Anyway ... using jQuery, how I would I clear the selection on the SELECT input element so no items are selected.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

In the case of a <select multiple> the .val() function takes/returns an array, so you can simply pass in an empty array to clear the selection, like this:

$("#selectID").val([]);

You can test it out here.

over 4 years ago · Santiago Trujillo Report

0

This worked to clear all selected options for me..

$("#selectListName").prop('selectedIndex', -1)

The select list looked like

<select multiple='multiple' id='selectListName'> 
  <option>1</option> 
  <option>2</option> 
  <option>3</option> 
  <option>4</option>
</select>
over 4 years ago · Santiago Trujillo Report

0

Try: // Just put # before select to fix this. Works perfect. $("#select option:selected").each(function () { $(this).remove(); //or whatever else });

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!