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

364
Views
After getting second select option value if second option value exist another div will hide

Actually, I am trying to hide div id="condition-description-sec" for the selected second option it's hiding, if I select another option but div id="condition-description-sec" not showing. How can I solve this issue please?

var optionValue = document.getElementById("condition-select")[1].value
console.log('test condition '+optionValue)
if(optionValue){ 
    $("#condition-description-sec").hide()
}else{
    $("#condition-description-sec").show()
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<select name="condition_id" id="condition-select">
    <option value="">Select Condition</option>                 
    <option value="1000/New with tags" selected>New with tags</option>
    <option value="1500/New without tags">New without tags</option>
    <option value="1750/New with defects">New with defects</option>
    <option value="3000/Used">Used</option>
</select>

<div id="condition-description-sec">
  <p>Lorem ipsum dolor amet</p>
</div>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use .change event to get the event. And I also split it into a function to check on page init.

$(document).ready(function(){
 
  // Declare function to check value to show/hide value
  var selectChangedFunc = function() {
    if ($('#condition-select').val() == '1000/New with tags') {
       $('#condition-description-sec').hide();
    } else {
       $('#condition-description-sec').show();
    }
  };

  // Call it on page loaded to make sure it hides on init.
  selectChangedFunc();

  // Capture change event to check status
  $('#condition-select').change(function() {
    selectChangedFunc();
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<select name="condition_id" id="condition-select">
    <option value="">Select Condition</option>                 
    <option value="1000/New with tags" selected>New with tags</option>
    <option value="1500/New without tags">New without tags</option>
    <option value="1750/New with defects">New with defects</option>
    <option value="3000/Used">Used</option>
</select>

<div id="condition-description-sec">
  <p>Lorem ipsum dolor amet</p>
</div>

about 4 years ago · Juan Pablo Isaza 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!