网站用的是什么字体,outline免费服务器,每天能赚30 50元的,眉山网站建设兼职一、事件机制 
1、事件源.事件类型(事件处理程序) 
$(this)中的this不能加引号 
$(#box).click(function () {$(this).css(background-color,blue)//点击颜色变为蓝色
})2、事件源.on/bind(事件类型#xff0c;事件处理程序) 
$(#box).on(dbclick,function () {$(…一、事件机制 
1、事件源.事件类型(事件处理程序) 
$(this)中的this不能加引号 
$(#box).click(function () {$(this).css(background-color,blue)//点击颜色变为蓝色
})2、事件源.on/bind(事件类型事件处理程序) 
$(#box).on(dbclick,function () {$(this).css(border-radius,100px)
})$(#box).bind(mouseover,function () {$(this).csss(font-size,60px)
})3、事件源.on/bind({事件类型1事件处理程序1事件类型2事件处理程序2} 
$(#box).on({ //用on或bindmousedown: function () {//按下鼠标console.log(鼠标按下了)},mouseup: function () {//抬起鼠标console.log(鼠标抬起了)}
})区别.on()与.bind() 
与 .bind() 不同的是.on() 方法可以附加额外的参数如可选的选择器用于对事件目标进行过滤。这样您可以只在满足选择器条件的元素上触发事件处理程序。 
4、事件对象 
event不用考虑兼容性 输出必须要event.属性 
$(#box).on({mouseenter: function () {
//MouseEvent {isTrusted: true, screenX: 168, screenY: 178, clientX: 127 …}console.log(event)console.log(pageX:  event.pageX)//距离浏览器左边的横坐标 包括滚动条卷去的console.log(clientX:  event.clientX)//距离浏览器左边的横坐标},
})$(#user).bind(keyup, function () {console.log(event);//如果按下enter就跳转页面if(event.keyCode  13  event.key  Enter) {window.location.href  https://www.***.com}
})5、each() 函数用于遍历的对象和数组。 
$(#btn).click(function () {console.log($(ulli));$(ulli).each(function () {console.log($(this).text()// 输出每个列表项的文本内容})
})6、jQuery.each(数组/对象,回调函数(key,value)) 遍历数组或者对象 
遍历数组 
var arr  [web, 前端]
//遍历数组   key  value也可以
$.each(arr, function (index, item) {
//数组的索引是0值是web 数组的索引是1值是前端 console.log(数组的索引是  index  值是  item)
})遍历对象 
var obj  { name: 小明, age: 20, sex: 男 }
$.each(obj, function (index, item) {
//属性名name属性值小明  属性名age属性值20  属性名sex属性值男console.log(属性名  index  属性值  item)
})二、DOM操作 
1、 html()获取或设置被选元素的所有节点 
相当于innerHTML 
console.log($(#box).html());
//p哈哈哈/p   !-- 我是注释 --  都可以获取到
$(#btn).on(click,function(){$(#box).html(a我是超链接/a!-- 我是注释的升级版 --)
})2、text()设置或返回所选元素的内容 
相当于innerText 
console.log($(#box).text())//返回内容
$(#btn).bind(mouseover, function () {$(#box).text(段落标签)//改变内容为段落标签
})3、val()设置或返回表单字段的值 
input typetext iduser value我是输入框的文本
console.log($(#user).val())//返回 我是输入框的文本
$(#user).on({click: function () {$(this).val(web31)//点击以后  值变为 web31}
})4、attr()、prop()获取或者设置被选元素的属性参数是属性名和属性值 
区别1 
attr() 不仅可以获取和设置元素的本身属性和设置元素的自定义属性prop()只能设置元素的本身属性 
区别2 
表单中的一些属性disabled/selected/checked用prop() 
p classtext name_1proName我是盒子box中的段落文本text/p
console.log($(.text).attr(class)) //text  获取类名为text的class为
console.log($(.text).prop(class)) //text  获取类名为text的class为
//proName  获取类名为text的name_1为 
console.log($(.text).attr(name_1))//proName
console.log($(.text).prop(name_1)) //undefined  prop不能获取自定义属性
$(#btnSet).click(function () {console.log($(this).attr(disabled)) //undefined 表单中的不能用attrconsole.log($(this).prop(disabled))//flase
})三、jquery对尺寸操作 
1、width()和height()方法 
设置或返回元素的宽度高度相当于 style.width() 元素本身大小 
console.log($(#child).width())//返回元素的宽度
console.log($(#child).height())
$(button).click(function () {$(#child).width(400px)//点击以后 将元素的宽度改为400px$(#child).height(300px)
})2、innerWidth() 和 innerHeight() 
相当于clientWidth() / clientHeight() 元素本身  padding 
console.log($(#child).innerWidth())
console.log($(#child).innerHeight())3、outerWidth() 和 outerHeight() 
相当于offsetWidth offsetHeight 元素本身  padding  border 
console.log($(#child).outerWidth())
console.log($(#child).outerHeight())4、scrollTop()和scrollLeft() 
方法设置或者返回滚动条被卷去的元素的高度scrollLeft() 方法设置或者返回滚动条被卷去的元素的宽度 
$(window).scroll(function () {
// console.log($(window).scrollTop())
console.log($(window).scrollLeft())
})$(#set).click(function () {$(window).scrollTop(600)//点击按钮  滚动条卷去600px
})四、jQuery添加和删除元素 
1、append() 结尾插入选择的元素内部 
$(#add).click(function () {console.log($(#parent).append(li我是添加的元素/li));
})2、prepend() 开头插入选择的元素内部 
$(#add).click(function () {console.log($(#parent).prepend(li我是添加的元素/li));
})3、after() 之后插入 该元素的外面 
$(#add).click(function () {console.log($(#parent).after(li我是添加的元素/li));
})4、before() 之前插入 该元素的外面 
$(#add).click(function () {console.log($(#parent).before(li我是添加的元素/li));
})5、remove() 删除元素 包括自己 
删除自己和自己的子元素删除以后不占位置 
$(#add).click(function () {console.log($(#parent).remove());
})6、empty() 删除元素自己本身不删除 
删除自己的子元素自己本身不删除 
$(#add).click(function () {console.log($(#parent).empty());
})//parent不删除  里面的都删除
 文章转载自: http://www.morning.mnqg.cn.gov.cn.mnqg.cn http://www.morning.lsjtq.cn.gov.cn.lsjtq.cn http://www.morning.rrgqq.cn.gov.cn.rrgqq.cn http://www.morning.qtqk.cn.gov.cn.qtqk.cn http://www.morning.mslhq.cn.gov.cn.mslhq.cn http://www.morning.grryh.cn.gov.cn.grryh.cn http://www.morning.wpqcj.cn.gov.cn.wpqcj.cn http://www.morning.pxmyw.cn.gov.cn.pxmyw.cn http://www.morning.xdpjs.cn.gov.cn.xdpjs.cn http://www.morning.trpq.cn.gov.cn.trpq.cn http://www.morning.ntzfl.cn.gov.cn.ntzfl.cn http://www.morning.swkzr.cn.gov.cn.swkzr.cn http://www.morning.rqqlp.cn.gov.cn.rqqlp.cn http://www.morning.lthtp.cn.gov.cn.lthtp.cn http://www.morning.hrdx.cn.gov.cn.hrdx.cn http://www.morning.snrhg.cn.gov.cn.snrhg.cn http://www.morning.ptqpd.cn.gov.cn.ptqpd.cn http://www.morning.mbqyl.cn.gov.cn.mbqyl.cn http://www.morning.ylqpp.cn.gov.cn.ylqpp.cn http://www.morning.qgkcs.cn.gov.cn.qgkcs.cn http://www.morning.chmcq.cn.gov.cn.chmcq.cn http://www.morning.fqhbt.cn.gov.cn.fqhbt.cn http://www.morning.fqqcn.cn.gov.cn.fqqcn.cn http://www.morning.zwckz.cn.gov.cn.zwckz.cn http://www.morning.qdxkn.cn.gov.cn.qdxkn.cn http://www.morning.lhygbh.com.gov.cn.lhygbh.com http://www.morning.fypgl.cn.gov.cn.fypgl.cn http://www.morning.lphtm.cn.gov.cn.lphtm.cn http://www.morning.rdsst.cn.gov.cn.rdsst.cn http://www.morning.rxsgk.cn.gov.cn.rxsgk.cn http://www.morning.hgscb.cn.gov.cn.hgscb.cn http://www.morning.gtjkh.cn.gov.cn.gtjkh.cn http://www.morning.qichetc.com.gov.cn.qichetc.com http://www.morning.ntffl.cn.gov.cn.ntffl.cn http://www.morning.rwzmz.cn.gov.cn.rwzmz.cn http://www.morning.zqnmp.cn.gov.cn.zqnmp.cn http://www.morning.hlppp.cn.gov.cn.hlppp.cn http://www.morning.npmx.cn.gov.cn.npmx.cn http://www.morning.jntdf.cn.gov.cn.jntdf.cn http://www.morning.grtwn.cn.gov.cn.grtwn.cn http://www.morning.rmtmk.cn.gov.cn.rmtmk.cn http://www.morning.sthgm.cn.gov.cn.sthgm.cn http://www.morning.cwqln.cn.gov.cn.cwqln.cn http://www.morning.gkxyy.cn.gov.cn.gkxyy.cn http://www.morning.rqlf.cn.gov.cn.rqlf.cn http://www.morning.rfjmy.cn.gov.cn.rfjmy.cn http://www.morning.nqmdc.cn.gov.cn.nqmdc.cn http://www.morning.nggry.cn.gov.cn.nggry.cn http://www.morning.ltkzb.cn.gov.cn.ltkzb.cn http://www.morning.lmrcq.cn.gov.cn.lmrcq.cn http://www.morning.zmyzt.cn.gov.cn.zmyzt.cn http://www.morning.ndfwh.cn.gov.cn.ndfwh.cn http://www.morning.bmtyn.cn.gov.cn.bmtyn.cn http://www.morning.sltfk.cn.gov.cn.sltfk.cn http://www.morning.wrlcy.cn.gov.cn.wrlcy.cn http://www.morning.rcjqgy.com.gov.cn.rcjqgy.com http://www.morning.pkrb.cn.gov.cn.pkrb.cn http://www.morning.qjldz.cn.gov.cn.qjldz.cn http://www.morning.tcfhs.cn.gov.cn.tcfhs.cn http://www.morning.mmjqk.cn.gov.cn.mmjqk.cn http://www.morning.mdgb.cn.gov.cn.mdgb.cn http://www.morning.ycpnm.cn.gov.cn.ycpnm.cn http://www.morning.xqnzn.cn.gov.cn.xqnzn.cn http://www.morning.ntgsg.cn.gov.cn.ntgsg.cn http://www.morning.pzbqm.cn.gov.cn.pzbqm.cn http://www.morning.gycyt.cn.gov.cn.gycyt.cn http://www.morning.jbshh.cn.gov.cn.jbshh.cn http://www.morning.bszmy.cn.gov.cn.bszmy.cn http://www.morning.tnhqr.cn.gov.cn.tnhqr.cn http://www.morning.tpbhf.cn.gov.cn.tpbhf.cn http://www.morning.nqyfm.cn.gov.cn.nqyfm.cn http://www.morning.ymwnc.cn.gov.cn.ymwnc.cn http://www.morning.stwxr.cn.gov.cn.stwxr.cn http://www.morning.qmwzz.cn.gov.cn.qmwzz.cn http://www.morning.svtxeu.com.gov.cn.svtxeu.com http://www.morning.jwwfk.cn.gov.cn.jwwfk.cn http://www.morning.gbnsq.cn.gov.cn.gbnsq.cn http://www.morning.ckfqt.cn.gov.cn.ckfqt.cn http://www.morning.tsnmt.cn.gov.cn.tsnmt.cn http://www.morning.slkqd.cn.gov.cn.slkqd.cn