-1
私のグーグルでグーグルではありましたが、私の質問に適切な答えが見つかりませんでした。私がコード構造全体を変更する必要があり、それが私が正確に望むものではないということだけが役立つオンラインのソリューションがいくつかあります。addEventListenerに複数のイベント(サイズ変更と読み込み)をバインドする方法
window.addEventListener('DOMContentLoaded', function(event) {
if(window.matchMedia("(min-width: 767px)").matches){
Array.prototype.slice.call(document.getElementsByClassName("tabcontent")).forEach(function(element, index) {
element.addEventListener("mouseleave", function(event) {
\t \t event.target.style.display = "none";
});
document.getElementById("categories-list-box").addEventListener("mouseleave", function(event) {
if (event.relatedTarget.className.indexOf("tabcontent") == -1) {
\t tabcontent = document.getElementsByClassName("tabcontent");
\t for (i = 0; i < tabcontent.length; i++) {
\t tabcontent[i].style.display = "none";
\t }
}
})
});
}
})
それを呼び出すあなたがバインドする方法を求めていますth複数のイベントと同じ機能ですか? –
あなたのコードが無効な場合、コードスニペットは無意味です – GingerPlusPlus
また、インデントを修正してください – GingerPlusPlus