Javascript 关于在jQuery中使用单开关Botton切换函数的问题
我使用两个按钮在以下位置上上下滑动页面:Javascript 关于在jQuery中使用单开关Botton切换函数的问题,javascript,jquery,Javascript,Jquery,我使用两个按钮在以下位置上上下滑动页面: Go信息 地图 你能告诉我如何减少按钮来做同样的工作吗?比如: <button type="button" class="btn btn-default slider">Switch View</button> 切换视图 jQuery jQuery('body').css('overflow','hidden'); var viewheight = $('#map').height(); $('.goin
Go信息
地图
你能告诉我如何减少按钮来做同样的工作吗?比如:
<button type="button" class="btn btn-default slider">Switch View</button>
切换视图
jQuery
jQuery('body').css('overflow','hidden');
var viewheight = $('#map').height();
$('.goinfo').fadeIn();
$(window).scroll(function () {
if ($(this).scrollTop() < 100) {
$('.goinfo').fadeIn();
} else {
$('.goinfo').fadeOut();
}
});
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('.gomap').fadeIn();
} else {
$('.gomap').fadeOut();
}
});
$('.gomap').click(function () {
$("html, body").animate({
scrollTop: 0
}, 600);
return false;
});
$('.goinfo').click(function () {
$("html, body").animate({
scrollTop: viewheight
}, 600);
return false;
});
$( window ).resize(function() {
var mapheight = $('#mapview').height();
});
jQuery('body').css('overflow','hidden');
var viewheight=$('#map').height();
$('.goinfo').fadeIn();
$(窗口)。滚动(函数(){
if($(this).scrollTop()<100){
$('.goinfo').fadeIn();
}否则{
$('.goinfo').fadeOut();
}
});
$(窗口)。滚动(函数(){
如果($(this).scrollTop()>100){
$('.gomap').fadeIn();
}否则{
$('.gomap').fadeOut();
}
});
$('.gomap')。单击(函数(){
$(“html,body”).animate({
滚动顶部:0
}, 600);
返回false;
});
$('.goinfo')。单击(函数(){
$(“html,body”).animate({
scrollTop:viewheight
}, 600);
返回false;
});
$(窗口)。调整大小(函数(){
var mapheight=$('#mapview').height();
});
div
s的外面,它们下面位置:绝对;底部:10px;右;10px;
),但是如果不了解更多关于页面的信息,很难说ready
处理程序:var down=false;
jQuery('body').css('overflow','hidden');
var viewheight = $('#map').height();
$('.goinfo').fadeIn();
$(window).scroll(function () {
if ($(this).scrollTop() < 100) {
$('.goinfo').fadeIn();
} else {
$('.goinfo').fadeOut();
}
});
$(window).scroll(function () {
if ($(this).scrollTop() > 100) {
$('.gomap').fadeIn();
} else {
$('.gomap').fadeOut();
}
});
$('.gomap').click(function () {
$("html, body").animate({
scrollTop: 0
}, 600);
return false;
});
$('.goinfo').click(function () {
$("html, body").animate({
scrollTop: viewheight
}, 600);
return false;
});
$( window ).resize(function() {
var mapheight = $('#mapview').height();
});
if (down) {
down = false;
$('html, body').animate(...);
}
else {
down = true;
$('html, body').animate(...);
}