jquery “做页面滚动到某屏时改变状态标题” 所用知识点记录

浏览器滚动条滚动时触发事件

    //浏览器滚动条滚动时触发事件
    $(window).scroll(function(){});

浏览器窗口大小改变时触发事件

    //浏览器窗口大小改变时触发事件
    $(window).resize(function(){});

监听所有锚点链接实现平滑移动

    //监听所有锚点链接实现平滑移动
    $(‘a[href*=#],area[href*=#]‘).click(function() {
        if (location.pathname.replace(/^\//, ‘‘) == this.pathname.replace(/^\//, ‘‘) && location.hostname == this.hostname) {
            var $target = $(this.hash);
            $target = $target.length && $target || $(‘[name=‘ + this.hash.slice(1) + ‘]‘);
            if ($target.length) {
                var targetOffset = $target.offset().top;
                //为提升用户体验,做出算法改进 start
                var clientHeight    =    document.body.clientHeight;    //浏览器可视高度
                targetOffset    =    targetOffset-(clientHeight/2)+100;
                //end
                $(‘html,body‘).stop(true).animate({
                    scrollTop: targetOffset
                },
                1000);
            return false;
            }
        }
    });

获取某元素基于当前浏览器窗口底部的距离

//获取某元素基于当前浏览器窗口底部的距离
function get_element_window_bottom(choose){
    if(choose==‘‘) return false;
    mTop = $(choose)[0].offsetTop;
    sTop = $(window).scrollTop();
    result = mTop - sTop;
    //增加一个算法提高用户体验度
    result    =    result+parseInt(document.body.clientHeight/2);
    return     result;
}

效果实例图

时间: 2024-08-10 23:16:49

jquery “做页面滚动到某屏时改变状态标题” 所用知识点记录的相关文章

jQuery实现页面滚动时智能浮动定位

<!DOCTYPE html><html><head>    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    <title>jQuery实现页面滚动时层智能浮动定位_前端开发</title>    <style type="text/css">        * { 

页面滚动到一定位置时才显示在指定位置上的元素的jquery代码

当前可视窗口的顶部到页面的顶部高度+可视页面的高度>元素的绝对高度+元素自身高度时,显示当前元素. 页面滚动到一定位置时才显示在指定位置上的元素! 将$(".timeline.animated .timeline-row")换成指定的选择器即可! (function() {  $(document).ready(function() {    var timelineAnimate;    timelineAnimate = function(elem) {      retur

js原生 + jQuery实现页面滚动字幕

js原生/jQuery实现页面滚动字幕效果 17:45:49 在新闻列表或者文章列表信息等页面中很容易要求实现字幕滚动的效果,以下为简单的实现页面中滚动字幕的效果 1.jQuery实现页面滚动字幕效果 代码如下: <div class="box"> <ul class="list"> <li>这是滚动加载的第1条数据</li> <li>你猜猜这是第几条滚动加载的文字</li> <li>

页面内容小于一屏时仍能头部在头部尾部在尾部

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>页面内容小于一屏时仍能头部在头部尾部在尾部</title> <style> *{ padding:0; margin:0; text-align:center; } /* html, body {height: 100%;}*/ header{

jQuery判断页面滚动到底部

有时候我们需要页面滚动到底部的时候去加载更多的数据,实现思路基本上就是判断浏览器页面是否滚动到了页面底部,当滚动到页面底部的时候,用AJAX异步获取数据然后加载到页面中. 利用jQuery判断浏览器页面是否滑动到了底部: <script type="text/javascript"> // scroll event $(window).scroll(function(){ // scroll at bottom if ($(window).scrollTop() + $(w

[jquery]判断页面滚动到顶部和底部(适用于手机web加载)

//判断页面滚动到顶部和底部 $(window).scroll(function(){ var doc_height = $(document).height(); var scroll_top = $(document).scrollTop(); var window_height = $(window).height(); if(scroll_top == 0){ alert("到顶啦"); }else if(scroll_top + window_height >= doc

基于jQuery实现页面滚动时顶部导航显示隐藏效果

<!DOCTYPE html> <html lang="zh-cn"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Title</title> <link rel=&quo

jquery使页面滚动到底部

function scrollToEnd(){//滚动到底部 var h = $(document).height()-$(window).height(); $(document).scrollTop(h); } (摘抄自http://www.cnblogs.com/hui-blog/p/5526278.html)

jquery让页面滚动到底部

function scrollToEnd(){//滚动到底部 var h = $(document).height()-$(window).height(); $(document).scrollTop(h); }