Answer the question
In order to leave comments, you need to log in
Closing one element when another is clicked?
Good day. There are two two drop-down lists, and I can't figure out how to make it so that when you click on one, the other list closes.
$(function(){
$('.selected').click(function(){
$('.option-list').slideToggle(200);
$('.select').toggleClass('select-active');
});
$('.option').click(function(){
select_val = $(this).attr('data-select-val');
select_div = $(this).parent().parent();
$(select_div).children('.selected').html($(this).html());
$(select_div).children('input').val(select_val);
$('.option-list').slideToggle(200);
$('.select').toggleClass('select-active');
});
});
$(function(){
$('.selected-two').click(function(){
$('.option-list-two').slideToggle(200);
$('.select-two').toggleClass('select-active-two');
});
$('.option-two').click(function(){
select_val = $(this).attr('data-select-val');
select_div = $(this).parent().parent();
$(select_div).children('.selected-two').html($(this).html());
$(select_div).children('input').val(select_val);
$('.option-list-two').slideToggle(200);
$('.select-two').toggleClass('select-active');
});
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question