JS onchange事件

<select name="" id="yinliao"> <option value="0">白开水</option> <option value="1">矿泉水</option> <option value="2">白酒</option> <option value="3"...

Read more

JS 焦点事件

input{ width:200px; height:20px; border:solid 1px #ddd; } <input type="text" /> <input type="text" /> <input type="text" /> <input type="text" id="username" /> <...

Read more

JS 键盘事件、防止页面元素被复制

键盘事件<input type="text" id="username" value="iloveyou"> <script type="text/javascript"> //获取元素 var username = document.getElementById('username'); // on 当...时候 key按键 down向下的 ...

Read more

JS 拖动div效果

<style> * { margin:0px; padding:0px; } #move { width:200px; height:200px; background:orange; position:absolute; } </style> <div id="move"></div> <sc...

Read more

JS 鼠标按下 onmousedown onmouseup

<div style="width:300px;height:300px;background:#456"></div> var div = document.getElementsByTagName('div')[0]; //绑定事件 div.onmousedown = function() { alert('鼠标被按下了啊!!!'); } div.onmou...

Read more

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-size:20px;"...

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{ list-style:none;...

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'; } </scri...

Read more