我有一个jQuery函数,每次点击都会给我第二个函数。我该如何停止这种情况?
我有一个导航栏,其中包含3个链接,对于每个链接,我都有一个具有不同id的.contentDiv。每当有人单击其中一个链接时,切换功能就会发生;隐藏除与该链接相关联的那个.contentDiv之外的所有.contentDiv,并对该.contentDiv执行向左滑动的动画。
HTML:
.navbar
ul
li
a.about(href='#') About
span
span
li
a#portfolio(href='#') HOME
span
span
li
a(href='#') Contact
span
span
.contentDiv#portfolioContent
.title About
.content
.fse
p Lorem ipsum dolor sit amet, consectetur adipiscing elit.
CSS:
.contentDiv {
transform: skew(45deg);
width: 100%;
height: 100%;
position: relative;
top: 5%;
left: 300%;
overflow: hidden;
}
.title {
position: absolute;
top: 30%;
left: 30%;
font-size: 500%;
font-family: Raleway;
font-weight: 800;
color: #EAEBED;
}
.content {
width: 100%;
height: 50%;
top: 43%;
left: 3%;
font-size: 130%;
font-family: Raleway;
color: #EAEBED;
position: absolute;
overflow:scroll;
padding-bottom: 7%;
}
Jquery:
$('.about').click(function () {
$("#aboutContent").toggle(
function() {
$("#aboutContent").animate({left: "115%"}, { //coming out of hiding
duration: 2000
});
}, function() {
$("#aboutContent").animate({left: "300%"}, { //back into hiding
duration: 2000
});
}
);
});