Issue on Using One Switch Botton to Toggle Functions in jQuery
I am using two buttons to slide up and down the page at
this sample
as:
- <div id="map"><button type="button" class="btn btn-default green goinfo">Go Info</button></div>
- <div id="info"> <button type="button" class="btn btn-default green gomap">Go Map</button></div>
can you please let me know how I can reduce the buttons to do do the same job? something like :
- <button type="button" class="btn btn-default slider">Switch View</button>
and this is the jQuery that I have
- 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();
- });
Thanks