前端个人---笔记

一 .css方面

二 .js方向

(1)获取当前浏览器可视宽度和高度(不是整体BODY)

JQ: $(window).width()

$(window).height()

 

 

(2)获取整个浏览器宽度高度

JQ:

$(document).width() < $('body').width() ? $(document).width() : $('body').width();

$(document).height() < $('body').height() ? $(document).height() : $('body').height();

 

 

(3)图片放大的插件:zoomify.js

 

 

(4)PC鼠标长按方法调用

JQ:

//这是鼠标点下的时候执行,在里面写一个timeout定时器模拟多少秒后执行触发的函数

$("...").mousedown(function(){   })

//这是鼠标抬上的时候执行的函数,在里面清除timeout定时器

$("...").mouseup(function(){  })

 

(5)获取浏览器域名和HTTP

 window.location.protocol+"//"+window.location.host

 

(6)获取当前滚动条距离顶部的高度

JQ:

$(document).scrollTop()

(7)滚动条事件

object.addEventListener("scroll", myScript);

object:获取节点(this.$refs.mypklogList //vue的写法 mypklogList是表现中 ref=“mypklogList”)

 

如果是监听整个浏览器的

var scrolltop=null;

window.onscroll=function(e){

var e=e;

scrolltop=document.documentElement.scrollTop;

if(scrolltop > 150){

.....

}else{

....

}

 

}

 

(8)隐藏滚动条:nicescroll.js

https://blog.csdn.net/zyy_0725/article/details/80436258

 

(9)JQ通过onclick方法获取节点查找相对应的节点

 $(event.currentTarget).closest('.list_content1').next('.box').find('.small-image').children('.kyo'));

  data.each(function(index,element){

         if(index==0){

                 $(this).addClass('haha')

         }

原文地址:https://www.cnblogs.com/kyooo/p/13276714.html