var sidebar = document.getElementById('显示或隐藏的元素');
var overlay = document.getElementById('div元素id');
var yyy = document.getElementById('按钮元素id');
function 函数名() {
sidebar.classList.toggle('active');
overlay.style.display = sidebar.classList.contains('active') ? 'block' : 'none';
sidebar.style.display = sidebar.classList.contains('active') ? 'block' : 'none';
yyy.innerHTML = sidebar.classList.contains('active') ? 'X' : '≡';
}