Javascript jQuery联系人切换菜单
我正在尝试创建一个切换菜单,但是用于切换功能的jQuery(/contact让我知道toggle/)不起作用,我不知道为什么 非常感谢您的帮助:-) CSS: jQuery:Javascript jQuery联系人切换菜单,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我正在尝试创建一个切换菜单,但是用于切换功能的jQuery(/contact让我知道toggle/)不起作用,我不知道为什么 非常感谢您的帮助:-) CSS: jQuery: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script> <script> jQuery(document).ready(function () { $(window)
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<script>
jQuery(document).ready(function () {
$(window).resize(function(){
if ($(window).width() >=850) {
$(".nav").show();
}
else{ $(".nav").hide();}
});
$('#toggle-menu').click(function () {
$(this).toggleClass('menu-is-active')
});
/* click outside of nav to trigger navigation icon animation*/
$(document).click(function () {
$("#toggle-menu").removeClass();
});
$("nav").click(function (e) {
e.stopPropagation();
return false;
});
/*----/----navigation icon animation*/
/*toggle menu*/
jQuery("#toggle-menu").click(function () {
jQuery(".nav").slideToggle();
});
/* click outside of nav to close toggle*/
$(document).click(function () {
if ($(window).width() < 850) {
$(".nav").hide();
} else {
$(".nav").show();
}
});
$("#toggle-menu").click(function (e) {
e.stopPropagation();
return false;
});
/*----/----toggle menu*/
/*Jump Scroll*/
$(function() {
var $window = $(window), $document = $(document),
transitionSupported = typeof document.body.style.transitionProperty === "string", // detect CSS transition support
scrollTime = 1; // scroll time in seconds
$(document).on("click", "a[href*=#]:not([href=#])", function(e) {
var target, avail, scroll, deltaScroll;
if (location.pathname.replace(/^\//, "") == this.pathname.replace(/^\//, "") && location.hostname == this.hostname) {
target = $(this.hash);
target = target.length ? target : $("[id=" + this.hash.slice(1) + "]");
if (target.length) {
avail = $document.height() - $window.height();
if (avail > 0) {
scroll = target.offset().top;
if (scroll > avail) {
scroll = avail;
}
} else {
scroll = 0;
}
deltaScroll = $window.scrollTop() - scroll;
// if we don't have to scroll because we're already at the right scrolling level,
if (!deltaScroll) {
return; // do nothing
}
e.preventDefault();
if (transitionSupported) {
$("html").css({
"margin-top": deltaScroll + "px",
"transition": scrollTime + "s ease-in-out"
}).data("transitioning", scroll);
} else {
$("html, body").stop(true, true) // stop potential other jQuery animation (assuming we're the only one doing it)
.animate({
scrollTop: scroll + "px"
}, scrollTime * 1000);
return;
}
}
}
});
if (transitionSupported) {
$("html").on("transitionend webkitTransitionEnd msTransitionEnd oTransitionEnd", function(e) {
var $this = $(this),
scroll = $this.data("transitioning");
if (e.target === e.currentTarget && scroll) {
$this.removeAttr("style").removeData("transitioning");
$("html, body").scrollTop(scroll);
}
});
}
});
/*----/----Jump Scroll*/
/*contact let me know toggle*/
jQuery(document).ready(function () {
$("#measure").hide();
$("#changetext").on('click', function() {
if($("#measure").is(":visible"))
return false;
$("#changetext").toggle();
this.value = this.value == 'send message' ? 'contact' : 'send message';
});
$("#send").on('click', function() {
$("#measure").toggle();
$("#changetext").val('thank you');
});
/*----/-----contact let me know toggle*/
});
</script>
jQuery(文档).ready(函数(){
$(窗口)。调整大小(函数(){
如果($(窗口).width()>=850){
$(“.nav”).show();
}
else{$(“.nav”).hide();}
});
$(“#切换菜单”)。单击(函数(){
$(this).toggleClass('menu-is-active')
});
/*单击导航外部以触发导航图标动画*/
$(文档)。单击(函数(){
$(“#切换菜单”).removeClass();
});
$(“导航”)。单击(功能(e){
e、 停止传播();
返回false;
});
/*----/----导航图标动画*/
/*切换菜单*/
jQuery(“切换菜单”)。单击(函数(){
jQuery(“.nav”).slideToggle();
});
/*单击导航外部以关闭切换*/
$(文档)。单击(函数(){
如果($(窗口).width()<850){
$(“.nav”).hide();
}否则{
$(“.nav”).show();
}
});
$(“#切换菜单”)。单击(功能(e){
e、 停止传播();
返回false;
});
/*----/----切换菜单*/
/*跳转卷轴*/
$(函数(){
变量$window=$(窗口),$document=$(文档),
transitionSupported=typeof document.body.style.transitionProperty==“string”//检测CSS转换支持
scrollTime=1;//以秒为单位滚动时间
$(文档)。在(“单击”,“a[href*=#]:not([href=#])”上,函数(e){
var目标、可用、滚动、deltaScroll;
if(location.pathname.replace(/^\/,“”))==this.pathname.replace(/^\/,“”)和&location.hostname==this.hostname){
target=$(this.hash);
target=target.length?目标:$(“[id=“+this.hash.slice(1)+”]);
if(目标长度){
avail=$document.height()-$window.height();
如果(有效值>0){
滚动=target.offset().top;
如果(滚动>可用){
滚动=有效;
}
}否则{
滚动=0;
}
deltaScroll=$window.scrollTop()-scroll;
//如果我们不必滚动,因为我们已经处于正确的滚动级别,
如果(!deltaScroll){
return;//什么也不做
}
e、 预防默认值();
如果(支持转换){
$(“html”).css({
“保证金顶部”:deltaScroll+“px”,
“转换”:scrollTime+“s ease in-out”
}).数据(“转换”,滚动);
}否则{
$(“html,body”).stop(true,true)//停止可能的其他jQuery动画(假设只有我们这样做)
.制作动画({
scrollTop:滚动+“px”
},滚动时间*1000);
返回;
}
}
}
});
如果(支持转换){
$(“html”)。在(“transitionend WebKittTransitionEnd msTransitionEnd oTransitionEnd”函数(e)上{
变量$this=$(this),
滚动=$this.data(“转换”);
if(e.target==e.currentTarget&&scroll){
$this.removeAttr(“样式”).removeData(“转换”);
$(“html,正文”).scrollTop(滚动);
}
});
}
});
/*----/----跳转卷轴*/
/*联系让我知道*/
jQuery(文档).ready(函数(){
$(“#度量”).hide();
$(“#changetext”)。在('click',function()上{
如果($(“#度量”)为(“:可见”))
返回false;
$(“#changetext”).toggle();
this.value=this.value=='send message'?'contact':'send message';
});
$(“#发送”)。在('单击',函数()上{
$(“#度量”).toggle();
$(“#changetext”).val(‘谢谢’);
});
/*----/-----联系让我知道*/
});
HTML:
1.
作品标题1
作品标题2
作品标题3
作品标题4
作品标题5
作品标题6
跟着我
版权所有©2015
你能发布一个JSFIDLE吗?只需在上面整理一下就可以解决问题。另外,试着一点一点地注释你的代码。jQuery中似乎有一些冗余。$('.toggle menu')。单击(function(){$('.nav').slideToggle();})
应该可以。但是,你需要审核你的代码。有很多语法错误。修复这些错误,你应该会没事的。试试看
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
<script>
jQuery(document).ready(function () {
$(window).resize(function(){
if ($(window).width() >=850) {
$(".nav").show();
}
else{ $(".nav").hide();}
});
$('#toggle-menu').click(function () {
$(this).toggleClass('menu-is-active')
});
/* click outside of nav to trigger navigation icon animation*/
$(document).click(function () {
$("#toggle-menu").removeClass();
});
$("nav").click(function (e) {
e.stopPropagation();
return false;
});
/*----/----navigation icon animation*/
/*toggle menu*/
jQuery("#toggle-menu").click(function () {
jQuery(".nav").slideToggle();
});
/* click outside of nav to close toggle*/
$(document).click(function () {
if ($(window).width() < 850) {
$(".nav").hide();
} else {
$(".nav").show();
}
});
$("#toggle-menu").click(function (e) {
e.stopPropagation();
return false;
});
/*----/----toggle menu*/
/*Jump Scroll*/
$(function() {
var $window = $(window), $document = $(document),
transitionSupported = typeof document.body.style.transitionProperty === "string", // detect CSS transition support
scrollTime = 1; // scroll time in seconds
$(document).on("click", "a[href*=#]:not([href=#])", function(e) {
var target, avail, scroll, deltaScroll;
if (location.pathname.replace(/^\//, "") == this.pathname.replace(/^\//, "") && location.hostname == this.hostname) {
target = $(this.hash);
target = target.length ? target : $("[id=" + this.hash.slice(1) + "]");
if (target.length) {
avail = $document.height() - $window.height();
if (avail > 0) {
scroll = target.offset().top;
if (scroll > avail) {
scroll = avail;
}
} else {
scroll = 0;
}
deltaScroll = $window.scrollTop() - scroll;
// if we don't have to scroll because we're already at the right scrolling level,
if (!deltaScroll) {
return; // do nothing
}
e.preventDefault();
if (transitionSupported) {
$("html").css({
"margin-top": deltaScroll + "px",
"transition": scrollTime + "s ease-in-out"
}).data("transitioning", scroll);
} else {
$("html, body").stop(true, true) // stop potential other jQuery animation (assuming we're the only one doing it)
.animate({
scrollTop: scroll + "px"
}, scrollTime * 1000);
return;
}
}
}
});
if (transitionSupported) {
$("html").on("transitionend webkitTransitionEnd msTransitionEnd oTransitionEnd", function(e) {
var $this = $(this),
scroll = $this.data("transitioning");
if (e.target === e.currentTarget && scroll) {
$this.removeAttr("style").removeData("transitioning");
$("html, body").scrollTop(scroll);
}
});
}
});
/*----/----Jump Scroll*/
/*contact let me know toggle*/
jQuery(document).ready(function () {
$("#measure").hide();
$("#changetext").on('click', function() {
if($("#measure").is(":visible"))
return false;
$("#changetext").toggle();
this.value = this.value == 'send message' ? 'contact' : 'send message';
});
$("#send").on('click', function() {
$("#measure").toggle();
$("#changetext").val('thank you');
});
/*----/-----contact let me know toggle*/
});
</script>
<div class="header">
<div class="navbar">
<a href="#panel1" class="logo" style="display: inline-block;">LogoPlaceHolder</a>
<a id="toggle-menu">
<div>
<span class="top"></span>
<span class="middle"></span>
<span class="bottom"></span>
</div>
</a>
<ul class="nav">
<li><a href="" style="display: inline-block; width:100%;">Home</a></li>
<li><a href="#panel9" style="display: inline-block; width:100%;">About</a></li>
<li><a href="#panel2" style="display: inline-block; width:100%;">Work</a></li>
<li><a href="#panel8" style="display: inline-block; width:100%;">Contact</a></li>
</ul>
</div>
</div>
<div class="maincontent">
<div class="panel multiplepanels" id="panel1">
<div class="inner"> 1 </div>
</div>
<div class="panel panel-blank multiplepanels" id="panel2">
<div class="inner"> <p>Work Title 1</p> <a href="" style="display: inline-block; width:100%;">View Project →</a> </div>
</div>
<div class="panel multiplepanels" id="panel3">
<div class="inner"> <p>Work Title 2</p> <a href="" class="links" style="display: inline-block; width:100%;">View Project →</a> </div>
</div>
<div class="panel panel-blank multiplepanels" id="panel4">
<div class="inner"> <p>Work Title 3</p> <a href="" style="display: inline-block; width:100%;">View Project →</a> </div>
</div>
<div class="panel multiplepanels" id="panel5">
<div class="inner"> <p>Work Title 4</p> <a href="" class="links" style="display: inline-block; width:100%;">View Project →</a> </div>
</div>
<div class="panel panel-blank multiplepanels" id="panel6">
<div class="inner"> <p>Work Title 5</p> <a href="" style="display: inline-block; width:100%;">View Project →</a> </div>
</div>
<div class="panel multiplepanels" id="panel7">
<div class="inner"> <p>Work Title 6</p> <a href="" class="links" style="display: inline-block; width:100%;">View Project →</a> </div>
</div>
<div id='wrapper' >
<input type='submit' value='Contact' id="changetext">
<div class='module' id='measure'>
<p></p>
<fieldset>
<legend></legend>
<input class="single" type='text' placeholder='Name' />
<input class="single" type='text' placeholder='Email' />
<input class="single" type='text' placeholder='Phone' />
<textarea class="message" type='text' placeholder='Message' > </textarea>
<input type='submit' id="send">
</fieldset>
</div>
</div>
<div class="follow">Follow Me</div>
<div class="social-buttons"><a href="#" class="social-button facebook"> <i class="fa fa-facebook"></i></a><a href="#" class="social-button twitter"><i class="fa fa-twitter"></i></a><a href="#" class="social-button google"><i class="fa fa-google"></i></a><a href="#" class="social-button dribbble"><i class="fa fa-dribbble"></i></a><a href="#" class="social-button skype"><i class="fa fa-skype"></i></a>
</div>
<div id="footer">
<p> Copywright © 2015 </p>
</div>