jquery切换不可点击
jquery toggle not clickable
本文关键字:jquery 更新时间:2024-06-14
我实现了一个Jquery隐藏/显示切换,它应该会影响菜单和子菜单。代码是有效的,但由于某些原因,它在我更广泛的站点代码的上下文中并不成功。我似乎搞不清楚问题出在哪里。有什么建议吗?http://studiopowell.net/TEST_gradient.html
JQuery:
$('.menu').click(function(e){
$(this).find('.submenu').fadeToggle();
});
$('.submenu').click(function(e){
e.stopPropagation();
});
html:
<div id="gradient">
<div id="contain">
<div class="titles"></div></div>
<div class="menu">W o r k<div class="submenu">I m a g e</div></div>
<div id="menu3"><a href="http://studiopowell.net" target="_blank">I n f o</a></div>
</div>
css:
#contain{
padding-top: -10px;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-direction: normal;
-moz-box-direction: normal;
-webkit-box-orient: vertical;
-moz-box-orient: vertical;
-webkit-align-content: center;
-ms-flex-line-pack: center;
align-content: center;
-webkit-box-align: center;
-moz-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-pack: center;
-moz-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
position: relative;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
}
.titles {
font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
font-size: 14px;
color:#33;
text-align:left;
padding-left: 0px;
padding-top: 25px;
padding-bottom: 20px;
margin-top: 50px;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-direction: normal;
-moz-box-direction: normal;
-webkit-box-orient: vertical;
-moz-box-orient: vertical;
-webkit-flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-box-pack: start;
-moz-box-pack: start;
-webkit-justify-content: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
-webkit-align-content: center;
-ms-flex-line-pack: center;
align-content: center;
-webkit-box-align: center;
-moz-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
position: relative;
z-index: 100;
}
.submenu {
font-family: Arial, "Helvetica Neue";
font-style:underline;
font-size: 12px;
color:#333;
opacity:0.3;
text-align:left;
padding-left: 100px;
padding-top: -100px;
margin-top: -14px;
padding-bottom: 100px;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-direction: normal;
-moz-box-direction: normal;
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-box-pack: center;
-moz-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-align-content: center;
-ms-flex-line-pack: center;
align-content: center;
-webkit-box-align: center;
-moz-box-align: center;
-webkit-align-items: center;
-ms-flex-align: center;
align-items: center;
position: absolute;
z-index: 8000;
}
.menu {
font-family: Arial, "Helvetica Neue";
font-style:underline;
font-size: 12px;
color:#333;
opacity:0.4;
text-align:left;
padding-left: 10px;
padding-top: -100px;
margin-top: -298px;
padding-bottom: 100px;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-direction: normal;
-moz-box-direction: normal;
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-box-pack: start;
-moz-box-pack: start;
-webkit-justify-content: flex-start;
-ms-flex-pack: start;
justify-content: flex-start;
-webkit-align-content: center;
-ms-flex-line-pack: center;
align-content: center;
-webkit-box-align: start;
-moz-box-align: start;
-webkit-align-items: flex-start;
-ms-flex-align: start;
align-items: flex-start;
position:relative;
z-index: 8040;
}
#menu3 {
font-family: Arial, "Helvetica Neue";
font-style:underline;
font-size: 12px;
color:#333;
opacity:0.4;
text-align:left;
padding-right: 10px;
padding-top: -100px;
margin-top: -114px;
margin-left:50%;
padding-bottom: 100px;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
-webkit-box-direction: normal;
-moz-box-direction: normal;
-webkit-box-orient: horizontal;
-moz-box-orient: horizontal;
-webkit-flex-direction: row;
-ms-flex-direction: row;
flex-direction: row;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
-webkit-box-pack: end;
-moz-box-pack: end;
-webkit-justify-content: flex-end;
-ms-flex-pack: end;
justify-content: flex-end;
-webkit-align-content: center;
-ms-flex-line-pack: center;
align-content: center;
-webkit-box-align: start;
-moz-box-align: start;
-webkit-align-items: flex-start;
-ms-flex-align: start;
align-items: flex-start;
position:relative;
z-index:9900;
}
我建议使用更有意义的类,比如。。。
<div class="menu">
Menu
<div class="submenu">Sub-Menu</div>
</div>
那么你的jQuery就是。。。
$('.menu').click(function(e){
$(this).find('.submenu').fadeToggle();
});
// If you don't want your sub-menu to trigger the toggle, add this:
$('.submenu').click(function(e){
e.stopPropagation();
});
相关文章:
- 无法从 jQuery RSS Feed 中的 localStorage 动态替换类
- 如何使用jQuery自动打开页面上的所有链接
- 如何使用jquery在填充自动完成的值后使文本框只读
- jQuery:循环一个具有不同超时值的循环
- 用程序搜索JQuery数据表中的文本
- 使用 jQuery 的 .on 函数如何获取事件的原始元素
- jQuery匹配JSON对象的部分文本
- Jquery POST未填充数组
- JQuery使计数器每次更改时都会增加
- 如何在Angular2中使用jQuery插件
- 提高JQuery的性能
- 无法在通过jQuery的ajax加载的页面中执行javascript
- JQuery合并了keyup和focusout两个函数
- 如何使用jQuery选择下拉列表的值
- 将PHP变量传递给jQuery时遇到问题
- jQuery UI自动完成突然停止工作
- 剑道网格jQuery动画()问题
- 如何使jQuery插件函数可调用以供独立使用,而不在集合上操作
- jquery点击函数select&取消选择
- jquery试图按名称获取按钮位置