当前位置: 首页 > news >正文

苏州网站建设代理黄页网址大全

苏州网站建设代理,黄页网址大全,吉安建设公司网站,百度云服务器11.事件 1.什么是事件 js属于事件驱动编程,把驱动,执行,调用通过一些交互,触发一些函数事件:发起--执行绑定事件--触发事件on 绑定 emit触发 off解绑2.事件分类 鼠标事件 点击事件 onclick 双击事件 ondblclick 按下事件 onmousedown 抬起事件 onmouseup 鼠标进…11.事件 1.什么是事件 js属于事件驱动编程,把驱动,执行,调用通过一些交互,触发一些函数事件:发起--执行绑定事件--触发事件on 绑定 emit触发 off解绑2.事件分类 鼠标事件 点击事件 onclick 双击事件 ondblclick 按下事件 onmousedown 抬起事件 onmouseup 鼠标进入事件 onmouseenter 鼠标离开事件 onmouseleave onmouseleave,onmouseenter遇到子元素,不会触发 鼠标移动事件 onmousemove 鼠标进入事件 onmouseover 上面两个遇到了子元素,会触发 鼠标离开事件onmouseout 鼠标滚轮 onmousewheel !DOCTYPE html html langenheadmeta charsetUTF-8meta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlestyle.box {width: 200px;height: 200px;background-color: skyblue;}.inner{width: 100px;height: 100px;background-color: pink;}/style /headbodydiv classboxdiv classinner/div/divscriptvar box document.querySelector(.box);// 1.单件事件 onclick// box.onclick function () {// alert(123)// }// 会覆盖前面的onclick事件box.onclick function () {console.log(onclick);}// 鼠标点击盒子,就会触发, 就像onclick(),执行// 2.双击box.ondblclick function () {console.log(ondblclick);}// 3.鼠标按下 onmousedown先执行,再执行onclickbox.onmousedown function () {console.log(onmousedown);}// 4.鼠标抬起onmousedown先执行,再执行onmouseup,最后onclickbox.onmouseup function () {console.log(onmouseup);}// 5.鼠标滚动事件box.onmousewheel function () {console.log(滚轮....onmousewheel);}// 6.鼠标进入box.onmouseenter function () {console.log(onmouseenter 鼠标进入);}// 7.鼠标离开box.onmouseleave function () {console.log(onmouseleave 鼠标离开);}// 8.鼠标进入box.onmouseover function () {console.log(onmouseover 鼠标进入);}// 9.鼠标离开box.onmouseout function () {console.log(onmouseout 鼠标离开);}// 1.// onmouseover 优先于onmouseenter// onmouseout优先于onmouseleave// 2.onmouseover 和onmouseout 遇到子元素也会触发// onmouseenter 和onmouseleave 遇到子元素不会触发// 10.鼠标移动box.onmousemove function () {console.log(onmousemove 鼠标移动);}/script /body/html键盘事件 键盘按下 onkeydown 获取不到输入框的完整内容,能防止别人误输入 键盘抬起 onkeyup 输入完成 后抬起,抬起的时候,就能获取输入的内容 非功能键 onkeypress 非功能键有用 html事件 onload 页面加载 并且外部资源也加载完成后,触发 ounload 卸载 onresize改变窗口大小事件 onselect 文本框选中事件 onchange 文本框改变内容事件 oninput 文本框输入事件 onfocus 光标聚焦事件 onblur 失去焦点 onwheel滚轮事件 onerror错误事件 onscroll 滚动条事件 oncontextmenu 右击菜单事件 表单** onsubmit 提交 .会触发js onsubmit事件return false;//阻止表单的默认行为,不让表单提交 onreset 重置 3.js的事件模式 内联模式(不推荐) 脚本模式(重点) 当一个元素上,绑定了内联模式与脚本模式时,脚本模式优先 4.事件对象 1.什么是事件对象 在交换时,产生一条记录对象 2.事件对象的默认写法 var eevt||window.event; window.event ie6 evt google 重点掌握 3.事件对象的属性 // button 监听按下了哪个键// type 事件的类型// charCode 字符编码// keyCode 按键编码// target 和srcElement// altKey// shiftKey// metaKey// clientX,clientY 客户// pageX,pageY 页面// screenX,screeY 屏幕// offsetX,offsetY 偏移// stopPropagation()//停止冒泡// cancelBubbletrue//取消冒泡// preventDefault()//阻止默认行为// returnValuefalse//阻止默认行为!DOCTYPE html html langenheadmeta charsetUTF-8meta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlestylehtml,body {height: 500%;}.box {width: 200px;height: 200px;background-color: pink;}/style /headbodydiv classbox/divscript/* e.button onmousedown 0左键 1 滚轮键 2 右键e.keyCode 没有小写 全是大写,13是回车键 37 38 39 40 左上右下e.key //按键的字符e.clientX,e.clientY 鼠标点击的点,到当前浏览器的左上角的距离e.pageX,e.pageY 鼠标点击的点,到页面左上角的距离e.offsetX,e.offsetY 鼠标点击的点,到当前元素左上角的距离e.screenX,e.screenY 鼠标点击的点,到当前屏幕左上角的距离e.target e.srcElement 鼠标点击的目标元素,target不一定等于thise.type 事件的类型,返回值不带on,列如onclick--clicke.altKey 是否按下了shiftKeye.ctrlKey 是否按下了CtrlKeye.metaKey window(win键)*/window.onmousedown function (evt) {var e evt || window.event// console.log(e.button);//onmousedown 0左键 1 滚轮键 2 右键}window.onkeydown function (evt) {var e evt || window.event// 没有小写 全是大写,13是回车键 37 38 39 40 左上右下// console.log(e.keyCode);console.log(e.key);//按键的字符}var box document.querySelector(.box)box.onclick function (evt) {var e evt || window.event;console.log(e.clientX, e.clientY);console.log(e.pageX, e.pageY);console.log(e.offsetX, e.offsetY);console.log(e.screenX, e.screenY);console.log(e.target, this);console.log(e.type);console.log(e.altKey);console.log(e.shiftKey);//按住shift 就返回true 否则falseconsole.log(e.ctrlKey);console.log(e.metaKey);}/script /body/html5.事件流 当元素叠到一起,点某一个元素,事件会传递 传递分为2个过程 冒泡和捕获 事件流有三个阶段 冒泡-目标-捕获 冒泡:从内到外传递事件 捕获 从外往内传递事件 6.事件的默认行为 表单,提交,重置行为a标签,跳转的行为图片,拖拽的行为右击菜单,显示菜单的行为 阻止默认行为 return false 重点 preventDefault()重点 returnValuefalse了解 兼容写法 了解 if (e.preventDefault) {e.preventDefault();} else {e.returnValue false;}7.事件的监听 addEventListener(“事件类型”,函数,true/false) capture 捕获 once 1次 addEventListener 默认是冒泡,就需要把第3个参数,设置true addEventListener和removeEventListener的第3个参数,统一为true或false 8.三大家族 三大家族 DOM的属性,而offsetX,offsetY是事件对象的属性 ​ offsetParent 找带有就近定位的父元素,如果父级们没有定位,默认找body 返回dom对象 ​ offsetLeft,offsetTop 获取当前元素到带有定位父元素的距离,默认到body的距离 返回数值 ​ offsetWidth offsetHeight 获取自身元素的宽与高自身宽高paddingborder,就是不包含margin 返回数值 ​ parentNode 找亲父元素(上一层) ​ offsetParent 找带有就近定位的父元素,如果父级们的没有定位,默认找body 9.案例盒子拖拽 !DOCTYPE html html langenheadmeta charsetUTF-8meta nameviewport contentwidthdevice-width, initial-scale1.0titleDocument/titlestyle.box {width: 200px;height: 200px;background-color: green;/* 位置移动 */position: absolute;}/style /headbodydiv classbox/divscriptvar box document.querySelector(.box)// 给盒子绑定鼠标按下事件box.onmousedown function (e) {// 获取拖动的点到盒子起始点的位置var disX e.pageX - this.offsetLeftvar disY e.pageY - this.offsetTop;// 在按下鼠标的同时,拖动盒子,绑定鼠标移动事件document.onmousemove function (e) {box.style.left e.pageX - disX pxbox.style.top e.pageY - disY px}// 鼠标松开不移动 清空绑定的移动事件// 文档的任何位置松开document.onmouseup function (e) {box.onmouseup document.onmousemove null}}/script /body/html
http://www.hkea.cn/news/14296370/

相关文章:

  • 餐饮网站建设方案网站英文联系我们
  • 做网站配置ui培训班好
  • 海纳网站建设成品网站w灬源码火龙果
  • 上海做原创网站广州微信网站建设哪家好
  • 企业网站建设哪家深圳好蜘蛛网站建设公司
  • 网站开发要学什么语言网站建设的几点体会
  • 欧莱雅官方网站的建设外贸销售
  • 建设网站怎么加购物车视频营销案例
  • 卖产品的网站怎么做有关建筑企业的网站有哪些
  • 外国网页设计网站系部网站建设中期检查表
  • 怎么做扫码进入网站wordpress所有文章
  • 昆山建设网站公司学会网页设计找什么工作
  • 深圳整站seo网站开发与制作中期报告
  • 在网站做博客百度手机快速排名点击软件
  • 重庆市住房和城乡建设部网站网站制作哪家便宜
  • 网站怎么显示备案号简易个人网站模板
  • 网站推广优化外链特价做网站
  • 校园网站的建设费用太原市做网站
  • 网站推广的网站作用建设摩托车是杂牌吗
  • 奎文营销型网站建设wordpress粒子北京
  • 北京网站制作公司报价百度云建站网站建设
  • 深圳外贸平台建站微信网站地址
  • 网站开发项目实训江阴做网站的公司
  • 东莞整站优化排名展厅宣传片
  • 莱芜网站建设公众号建设兰州市城关区建设局网站
  • 有什么免费开发网站建设软件为企业规划一个网站
  • 地产平面网站中国安能建设集团有网站
  • 公司网站建设提纲沈阳妇科检查
  • 智慧园区建设总体方案苏州seo推广
  • 金乡县住房和城乡建设局网站二手商品网站制作