Html5总结
首先在需要的页面加入如下js和css,就可以使用了。
<!--viewport的meta标签将屏幕的宽度设置为了与设备的宽度相同-->
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../style/-" />
<script src="../js/"></script>
<script src="../js/-"></script>
<script src="../js/"></script>
<script>
这里是你的js代码
</script>
功能代码介绍
1)定义变量
Var bianliang;或者var bianliang=null;
文档开始语句
$(document).ready(function(){
这里写你的js代码
});
定义函数
function click_function(){
你的函数代码
}
元素选择()里面的为解释
#id .class element(p、h1) E1,E2,E3(p,h1,li)
元素选择组合
E1 E2(E1下的所有E2)
E1>E2(选择E1下的子E2,不包含E2下满足的元素)
E1+ E(选择E1后紧相邻的E2) 等价$(E1).next(E2)
E1~ E2(选择E1之后的所有E2) 等价$(E1).nextAll(E2)
基本过滤
:first :last :not(E1) :even(所有偶数,从0开始) :odd(所有奇数) :eq(index) :gt(index) :lt(index) :header(所有标题元素h1~h5)
内容过滤器
:contains(text) :empty :has(E1) :parent(拥有该元素的所有div)
属性过滤器
:hidden(包括:<input type=“hidden”/>,<div style=“display:none”>和<div style=“visibility:hidden”>等,如果只选择<input>元素,则可以使用 $(“input:hidden”)
)
:visible
可见性过滤器
[attribute](有这个属性的) [attribute=value] [attribute!=value] [attribute^=value](选择以value开始的所有)
[attribute$=value](以value结束的元素) [attribute*=value](选择所有有value的元素) [A1][A2]
……[An](复合选择)
子元素选择器
:nth-child(index/even/odd/equation)(选择每个父元素下的相应元素)
:first-child :last-child($(“ul li:last-child”)选择每个ul下的最后一个<li>)
:only-child ($(“ul li:only-child”)在<ul>中选取是惟一子元素的<li>)
表单选择器
:input(匹配所有<input> <textarea> <select> <button>元素)
:text :password :radio :checkbox :submit :image :reset :button :file :hidden
给按钮绑定点击事件
$("#down_page").bind("click",function(){
这里写点击事件处理
}) ;
事件绑定方法
One bind【unbid】 live【die】(不存在也绑定) delegate【undelegate】(不存在也绑定) 优先 on【off】 (不存在也绑定)
事件
Blur focus/focusin/focusout load/unload resize scroll click /dbclick mousedown change select submit keydown/keypress/keyu
html5的js总结 来自淘豆网m.daumloan.com转载请标明出处.