jQuery toggleClass() not working
jQuery toggleClass() not working
我只是想知道如何在jQuery中创建一些开关。我想做的是有下载下拉菜单切换,当有人点击"下载"类工作与悬停效果,但不会为点击效果出于某种原因!任何帮助都太棒了!
JSFiddle: https://jsfiddle.net/830f119e/1/
<div class="navigation">
<div class="nav">
<div class="logo">
ZeteticRSPS
</div>
<ul>
<li><a href="#">Forum</a></li>
<li><a href="#">Store</a></li>
<li class="download-dropdown">
<a href="#" class="drop-btn">Download</a><i class="fa fa-caret-right nav-icon" aria-hidden="true"></i>
<div class="dropdown-content">
<a href="#">Mediafire</a>
<a href="#">Direct Download</a>
</div>
</li>
<li><a href="#">Vote</a></li>
</ul>
</div>
jQuery: $( "download-dropdown" ).click(function() {
$( this ).toggleClass( "download-dropdown-toggle" );
});
试试下面的代码。
$( ".download-dropdown a" ).click(function() {
$( this ).parent().find('.dropdown-content').slideToggle();
});
工作小提琴。
您没有在JSFiddle中选择jQuery
。
相关文章:
- $rootScope not working
- jQuery document.ready not working
- Javascript getElementsByTagName not working?
- JQuery.val( ) not working
- Tomcat websocket is not working
- Javascript JSON.parse not working
- NodeJS Multer is not working
- Regex not working
- Ember run.debounce not working
- AngularJs 1 not working
- document.getElementById.style.backgroundImage not working
- Rxjs5, distinct() is not working
- createOscillator noteOn not working
- Javascript - .getHours() not working
- Javascript setTimeout not working | onkeydown
- MongoDB $pull not working
- Express router.use not working
- JSONP not working
- window.opener not working in chrome & IE
- Backbone + RequireJS: Collection.each() is not working