JS 鼠标移动事件 mousemove

<style type="text/css"> *{ margin:0px; padding:0px; } div{ position:absolute; } </style> <div style="width:200px;height:200px;color:white;background:#345678;font-si...

Read more

JS 右键事件 oncontextmenu

<style type="text/css"> *{ margin:0px; padding:0px; } ul{ height:auto; width:120px; border:solid 1px #ddd; display:none; position:absolute; } li{ lis...

Read more

JS 双击事件

<div ondblclick="run(this)" style="width:200px;height:200px;background:#234567"> </div> <script type="text/javascript"> function run(obj) { obj.style.float = 'right'; } &lt...

Read more

JS 单击事件

单击事件<a href="http://www.baidu.com">百度</a> <script type="text/javascript"> //获取元素 var a = document.getElementsByTagName('a')[0]; //单击事件 a.onclick = function() { alert('我是百...

Read more

JS onload和onbeforeunload

<script type="text/javascript"> window.onload = function() { alert('页面加载完毕喽!!!!'); //获取元素 var test = document.getElementById('test'); test.onclick = function(){ ale...

Read more

JS 事件绑定

绑定事件 HTML元素事件属性 onclik="func();alert()" 元素对象的事件属性(匿名函数)addEventListener attachEvent 方法 第一种事件绑定的方式<div onclick="alert('gogogogo');alert('你干啥??');alert('没事儿啊!');alert('没事儿你点我干嘛???')"></div&g...

Read more

JS 事件、IE attachEvent

事件的三要素: 事件源、事件类型、事件的处理程序准备知识<style type="text/css"> div{ width:100px; height:100px; background:#123548; margin-bottom:20px; } .item{ b...

Read more

JS 随机概率

随机概率<button onclick="checkJiang()">点击抽奖啦</button> <script type="text/javascript"> function checkJiang(){ 随机获取一个数字 var num = rand(1,100); if(num <=20){ ...

Read more

JS 数学对象

计四舍五入(小数点后一位) var t = 3.46; var res = Math.round(t); // 3 var res = Math.round(4.6); 最大值 var res = Math.max(1,21,3,1,51,24,1,31,3,13,1,231,23,13,1,321,23,124,1,241); var res = Math.max(9...

Read more