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

136
Views
How to deselect select input with jquery?

I use this link for select option in my HTML pages(select2 in below).

enter image description here

My cod exist in JSFiddle too. I want deselect all with JQuery. I use so many code but not working for this option.

var elements = document.getElementById("field2").selectedOptions;

    for(var i = 0; i < elements.length; i++){
      elements[i].selected = false;
    }

or

document.getElementById("field2").value = "";

or

$('#field2').find($('option')).attr('selected',false)
almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0


<div>
 <input type="checkbox" id="miCheckbox" />
 <button id="deseleccionar">Deseleccionar</button>
</div>

JavaScript with jQuery:HTML:

 $(document).ready(function() {
 // Manejador para el botón de deselección
 $("#deseleccionar").click(function() {
 // Obtener la casilla de verificación (checkbox)
 const checkbox = $("#miCheckbox");

 // Deseleccionar la casilla de verificación
 checkbox.prop("checked", false);
 });
});
 $(document).ready(function() {
 // Manejador para el botón de deselección
 $("#deseleccionar").click(function() {
 // Obtener la casilla de verificación (checkbox)
 const checkbox = $("#miCheckbox");

 // Deseleccionar la casilla de verificación
 checkbox.prop("checked", false);
 });
});





almost 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!