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

213
Views
Hide Div based on select box using data-type not ID/Class

Is it possible to hide DIV based on the value of a select box (the select box doesn't have a unique ID or class). The only unique way I can see to possibly target it, is it has 'Data-type="location"'

<div class="bookly-form-group" data-type="location"><label>Location</label> <div><select><option value="0">Select location</option><option value="3">A Club</option><option value="4">B Club</option><option value="1">C Club</option><option value="6">Mobile Hire</option></select></div> </div>

On the drop-down code above, if the user selects "Mobile Hire" it should then show the DIV pasted below...otherwise the DIV should be hidden.

<div class="bookly-form-group" data-type="duration"><label>Duration</label> <div><select><option value="3">3 h (£120.00)</option><option value="4">4 h (£160.00)</option><option value="5">5 h (£200.00)</option><option value="6">6 h (£240.00)</option><option value="7">7 h (£280.00)</option><option value="8">8 h (£320.00)</option></select></div> </div>

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

0

What you want to achieve is done by the following code:

//First Import JQuery CDN, then Following Code inside a script tag

$(document).ready(function () {
  $('div[data-type="location"] select').on('change' , (function () {
      $('div[data-type="duration"]').hide();
  }));
});
Hope this helps!
about 4 years ago · Juan Pablo Isaza Report

0

Updated Code, this should work:

 //initially hide duration div
 $('div[data-type="duration"]').hide();

 $('div[data-type="location"] select').on('change' ,(function () {
    var value = $('div[data-type="location"] select option:selected').text();
    if(value === "Mobile Hire") {
        $('div[data-type="duration"]').show();
    }
    else {
        $('div[data-type="duration"]').hide();
    }
  }));
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!