如何使加号/减号可点击?现在不行...... 如果单击第二个按钮打开,如何关闭另一个按钮(下拉列表)?
$(".dropbtn").append('<span class="adl-signs"> +</span>');
function ctaDropMenu(e) {
e.target.nextElementSibling.classList.toggle("show");
}
function toggleSigns(e) {
$(e.target).find('.adl-signs').html(function(_, html) {
return $.trim(html) == ' +' ? ' -' : ' +';
});
}
$(".dropbtn").click( function(e) {
ctaDropMenu(e)
toggleSigns(e)
});
// Close the dropdown if the user clicks outside of it
window.onclick = function(event) {
if (!event.target.matches('.dropbtn')) {
var dropdowns = document.getElementsByClassName("dropdown-content");
var i;
for (i = 0; i < dropdowns.length; i++) {
var openDropdown = dropdowns[i];
if (openDropdown.classList.contains('show')) {
openDropdown.classList.remove('show');
}
}
}
}