Blogger Information
Blog 5
fans 0
comment 0
visits 14806
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
html中页面跳转到指定位置的三种方式
吃着青梅候竹马的博客
Original
3400 people have browsed it

在写页面交互的时候经常会遇到点击标题页面跳转到指定位置的操作,这里总结了三种方式

			$("#sl").on('tap', function(e) {
			    //方式一
			    window.location.hash="#sucaiLocal";    //点击后地址栏url会在原来url后边加上#bottombox,再次点击没有反应
			    
			    //方式二
		            var bottombox = document.getElementById("sucaiLocal");
			    bottombox.scrollIntoView();  //点击后地址栏url不会变化,可多次点击
                           
                            //方式三
			   $("html, body").animate({   //点击后地址栏url会在原来url后边加上#bottombox,再次点击没有反应
			       	scrollTop: $("#sucaiLocal").offset().top 
			    }, {
			    	duration: 500,easing: "swing"
			    });
			    return false;
			});


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post