JS 基础操作

数组的常用方法

    <script type="text/javascript">
        function getNowFormatDate() {
            var date = new Date();
            var seperator1 = "-";//设置成自己想要的日期格式 年-月-日
            var seperator2 = ":";//设置成自己想要的时间格式 时:分:秒
            var month = date.getMonth() + 1;//
            var strDate = date.getDate();//
            if (month >= 1 && month <= 9)
            {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9)
            {
                strDate = "0" + strDate;
            }
            var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
                + " " + date.getHours() + seperator2 + date.getMinutes()
                + seperator2 + date.getSeconds();
            return currentdate;
        }
        console.log(getNowFormatDate());
    </script>
获取当前时间
if (typeof(变量)=="undefound"){}
判断null 或 undefound
mouseout 里的子元素离开事件会一同出发父元素的mouseout
mouseleave 只有当鼠标离开该元素才会触发mouseleave
mouseout 和 mouseleave 的区别(鼠标离开事件)

 

JQ

width() - 返回元素的宽度。
height() - 返回元素的高度。
innerWidth() 方法返回元素的宽度(包括内边距)。                     
innerHeight() 方法返回元素的高度(包括内边距)。                    
outerWidth() 方法返回元素的宽度(包括内边距和边框)。               
outerHeight() 方法返回元素的高度(包括内边距和边框)。              
outerWidth(true) 方法返回元素的宽度(包括内边距、边框和外边距)。   
outerHeight(true) 方法返回元素的高度(包括内边距、边框和外边距)。  
返回文档(HTML 文档)$(document).height()的高度
返回窗口(浏览器视口)$(window).height()的高度
JQ取各种宽度
siblings() 方法返回被选元素的所有同胞元素。
下面的例子返回 <h2> 的所有同胞元素:

$(document).ready(function(){
  $("h2").siblings();
});


您也可以使用可选参数来过滤对同胞元素的搜索。
下面的例子返回属于 <h2> 的同胞元素的所有 <p> 元素:

$(document).ready(function(){
  $("h2").siblings("p");
});
同胞siblings()

 

posted @ 2019-01-23 21:35  小马_81  阅读(196)  评论(0)    收藏  举报