scrolltop

Scroll to last row having class in jQuery Dialog on open

心不动则不痛 提交于 2020-01-15 05:15:29
问题 Populating a jQuery UI Dialog with a longish table, I would like to have it scroll to the last row in the table having a specific class. I found two other posts almost identical to this here, and here, but I can't get it to work. I've mocked it up at jsFiddle in the hope that someone might help me see the error in my thinking on it. Here is the basic code jQuery(document).ready(function() { var content = jQuery('#amtz_div').html(); var title = 'Amortization Schedule'; var open = function() {

While Scrolling: if scrollTop() equals to or reaches a value execute event

自古美人都是妖i 提交于 2020-01-14 05:26:05
问题 I'm trying to fire an event when scrolling down to a certain point/value and execute again when scroll back up and down again. I tried: $(window).scroll(function(){ var sTop = $(this).scrollTop(); if(sTop == 300){ //execute event - failed } }); The above does not fire anything with the both mousewheel and dragging the scrollbar. but when I changed the condition to greater than or equal to, the event is being executed but multiple times when scrolling further down. if(sTop >= 300){ //execute

(document).height()、$(document).scrollTop()

独自空忆成欢 提交于 2020-01-13 12:55:01
(document).height()、$(document).scrollTop(),有需要的朋友可以参考下。 jQuery(window).height()代表了当前可见区域的大小,而jQuery(document).height()则代表了整个文档的高度,可视具体情况使用. 注意当浏览器窗口大小改变时(如最大化或拉大窗口后) jQuery(window).height() 随之改变jQuery(document).height()是不变的。 $(document).scrollTop() 获取垂直滚动的距离 即当前滚动的地方的窗口顶端到整个页面顶端的距离 $(document).scrollLeft() 这是获取水平滚动条的距离 要获取顶端 只需要获取到scrollTop()==0的时候 就是顶端了 要获取底端 只要获取scrollTop()>=(document).height()−(window).height() 就可以知道已经滚动到底端了 height:指元素内容的高度 ,jQuery中的height()方法返回的就是这个高度。 clientHeight:内容高度+padding高度 ,jQuery中的innerHeight()方法返回的就是这个高度。 offsetHeight:内容高度+padding高度+ 边框宽度 ,jQuery中的outerHeight(

Javascript: Programmatically scroll non-popup SELECT element to bottom in Chrome

风格不统一 提交于 2020-01-11 10:45:12
问题 I have a SELECT element in a web page, and I'd like it to load scrolled to the bottom. In most browsers, I can do this: myselect.scrollTop = myselect.scrollHeight; Although scrollHeight is out of bounds, the browsers figure that out and limit it appropriately. Except in Google Chrome. I could file a bug report, but that doesn't help me with my immediate problem. So I tried this: myselect.scrollTop = myselect.scrollHeight - myselect.clientHeight; But that subtracted too much -- there were

JS模拟瀑布流无限加载

萝らか妹 提交于 2020-01-11 02:51:42
效果图:随着鼠标往下滚动,不断加载生成不同颜色 大小的图片 HTML <div id= "content" > <ul></ul> <ul></ul> <ul></ul> <ul></ul> </div> CSS * { margin : 0 ; padding : 0 ; } #content { width : 1000px ; border : 1px dashed black ; margin : 0 auto ; overflow : hidden ; } #content ul { width : 240px ; padding : 5px ; float : left ; list-style-type : none ; } #content li { background-color : yellow ; font-size : 20px ; color : white ; text-align : center ; margin-bottom : 5px ; } JS //随机[m,n]之间的整数 封装 function randomNumber(m, n) { return Math. floor ( Math. random ( ) * ( n - m + 1 ) + m ) ; } //随机颜色 封装 function randomColor() {

DOM盒模型和位置 client offset scroll 和滚动的关系

流过昼夜 提交于 2020-01-09 10:30:30
DOM盒模型和位置 client offset scroll 和滚动的关系 概览 在dom里面有几个描述盒子位置信息的值, pading border margin width height client clientWidth 不要border clientHeight 不要border offset offsetTop offsetLeft offsetWidth 要border offsetHeight 要border scroll scrollTop scrollHeight scrollLeft scrollWidth 盒模型 生产环境一般使用 box-sizing: border-box, 效果: width == content.width + pading + border height == content.height + pading + border .antd-pro-pages-test-dom-index-box { box-sizing: border-box; width: 100px; height: 100px; padding: 5px; border-color: grey; border-style: solid; border-width: 5px; margin: 5px; } 滚动 <div class="container1"

vue路由跳转时定位在页面顶部

跟風遠走 提交于 2020-01-08 21:09:43
https://www.jianshu.com/p/950c673bcff9 背景 路由跳转时进入新的页面,但位置却不在顶部,而是在上个页面浏览的位置,在每次进入新页面时,想让它定位在页面的顶部。 代码 方式一 main.js router.beforeEach((to, from, next) => { // chrome document.body.scrollTop = 0 // firefox document.documentElement.scrollTop = 0 // safari window.pageYOffset = 0 next() }) 每次点击分页的时候,页面也会停留在之前浏览的位置,在调完接口后也加入下面几行代码就好了。 // chrome document.body.scrollTop = 0 // firefox document.documentElement.scrollTop = 0 // safari window.pageYOffset = 0 方式二 router-index.js const router = new VueRouter({ routes: [...], scrollBehavior (to, from, savedPosition) { // return 期望滚动到哪个的位置 return { x: 0, y: 0

vue实现数据上下滚屏效果

陌路散爱 提交于 2020-01-08 12:10:03
需求:实时数据滚屏效果,数据5s请求一次 实现: 思路:分两种情况:1、数据无溢出,即没有滚动条效果时,不处理滚屏效果 2、数据有溢出,处理滚屏效果 方案: 关键词: scrollTop //当前窗口显示的范围内的顶边的距离,也就是元素滚动条被向下拉动的距离。 offsetHeight : //返回元素的高度(包括元素高度、内边距和边框,不包括外边距) scrollHeight //返回元素的高度(包括元素高度、内边距和溢出尺寸,不包括边框和外边距),无溢出的情况,与clientHeight相同 具体参数了解参见 https://www.cnblogs.com/mycognos/p/9131180.html 代码: //方法 autoScroll ( ) { const element = document . getElementById ( "warningList" ) ; // 元素内容没有溢出时,不触发 if ( element . offsetHeight !== element . scrollHeight ) { if ( this . interval ) { clearInterval ( this . interval ) ; } element . scrollTop = this . scrollTop ; //重新赋值,初始值为0 this .

bootstrap里模态框调用后禁止页面滚动

不打扰是莪最后的温柔 提交于 2020-01-07 02:26:57
首先我们需要判断模态框是否已经被调用,这里使用bootstrap里提供的方法: // 监听点击事件,来触发页面是否滚动 // 定义两个函数,来禁止滚动和释放页面滚动 $ ( '.modal' ) . on ( 'show.bs.modal' , function ( e ) { stopScroll ( ) ; } ) $ ( '.modal' ) . on ( 'hidden.bs.modal' , function ( e ) { scrolling ( ) ; } ) /** * @method stopScroll 禁止页面滚动 * return 无 */ function stopScroll ( ) { // 定义一个函数来给body添加fixed属性 fixedBody ( ) ; // 为了兼容移动端,我们还需要做一下判断 var bodyWidth = $ ( 'body' ) . width ( ) ; // 并且给body添加modal-open类 $ ( 'body' ) . addClass ( 'modal-open' ) ; // 判断如果是移动端 if ( bodyWidth > 768 ) { // 移动端padding-right记得设置为17px. } } /** * @method scrolling 还原页面滚动 * return 无 */

JQuery page scroll issue with fixed header

笑着哭i 提交于 2020-01-06 05:48:11
问题 I'm using a line of JQuery to direct my users to the right part of my page when a link is clicked using the below code: $('html, body').animate({ scrollTop: $("#cell_" + scrollTo).offset().top }, 1500); It's working fine and scrolling to the correct point on the page. However I have a fixed nav bar (height: 49px; position: fixed;) on the site that sicks at the top of the page as it scrolls. The issue arises when the page scrolls down to the desired content, but then continues to scroll