我寫了這個函數綁定到一個按鈕,當點擊切換類提供下拉。唯一的問題是是,我有一個具有相同的功能在同一個頁面上的多個按鈕,它們都火當點擊一個:jQuery .click停止與點擊相同的類開放的所有元素
任何和所有幫助非常appricated :)
app.bind.DirectionDropdown = function(){
$('.direction-button').bind('click', function(){
$('.direction-dropdown').toggleClass('active');
\t
});
};
.fade-in {
visibility: hidden;
opacity: 0;
transition: visibility 0s,opacity .3s ease-in-out,all .3s ease-in-out;
-webkit-transition: visibility 0s,opacity .3s ease-in-out,all .3s ease-in-out;
-ms-transition: visibility 0s,opacity .3s ease-in-out,all .3s ease-in-out;
-moz-transition: visibility 0s,opacity .3s ease-in-out,all .3s ease-in-out;
}
.active {
visibility: visible;
opacity: 1;
transform: translate(0,0);
-webkit-transform: translate(0,0);
-moz-transform: translate(0,0);
-ms-transform: translate(0,0);
}
<a href="#" title="#" class="direction-button">Click to reveal text</a>
<div class="direction-dropdown fade-in">
<p>Reveal this</p>
</div>
<a href="#" title="#" class="direction-button">Click to reveal text</a>
<div class="direction-dropdown fade-in">
<p>Reveal this</p>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js"></script>
這是有道理的,但現在事件火災和沒有任何反應?你還有什麼建議嗎? – lucasjohnson
@lucasjohnson - 我能做的就是測試它,它似乎工作得很好 - > https://jsfiddle.net/21xj96up/ – adeneo
是的,你是對的。爲什麼它不在我的文件中一定有一個原因。 – lucasjohnson