When selectbox1 (.select-selected
) is clicked on, dropdown1 (.select-open
) displays. Correspondingly when selectbox2 is clicked on while dropdown1 is still open, dropdown1 will close, while dropdown2 will open. How do I do this? My current code does not work. My dropdown class .select-open
is a sibling element to the selectbox element (.select-selected
).
<div class="select-selected"></div> <div class="select-items select-open"></div>
$(".select-selected").click(function() { if ($(this).siblings(".select-items:not(this)").hasClass("select-open")) { // hide all select-open dropdowns that are not (this) select-open } $(this).show(); });