一、介绍和特点
二、jQuery的封装原理
闭包原理:在全局区中不能够获取函数体内的数据,使用更大作用域的变量来记录小作用域变量的值
jquery中的$(function(){}); 相当于window.οnlοad=function(){} $(document).ready(function(){});
三、jQuery的选择器(有很多种选择器,参考api文档)
id选择器: $("uname").val();
标签选择器: $("input").length;
类选择器: $(".common").length;
组合选择器: $("h3, input,...").length;
子选择器: $("div>input").length /$("#showdiv>input").length
四、jQuery操作元素属性
$("#uname").attr("属性名"); ---------实时的需要用val()获取
五、jQuery操作元素的内容
$("#showdiv").html();
$("#showdiv").text();
六、jQuery操作元素样式
$("#showdiv").css("background-color","orange"); / $("#showdiv").css({"background-color":"orange","border":"solid 1px"});
$("#showdiv").addClass("common"); / $("#showdiv").removeClass("common");
七、jQuery操作元素的文档结构
$("#showdiv").append("<i>饭</i>"); / appendTo()
prepend/prependTo
before/after
clone()
八、jquery中的事件
$("#btn").bind("click",function(){函数体}); -----绑定事件 /$("#btn").click(function(){xxx});
$("#btn").unbind("click"); -----解绑
$(document).ready(function(){xxx}); -----页面载入事件 /$(function(){xxx});
九、jquery中的动画效果
$("#showdiv").show(3000); -----3秒渐变显示
$("#showdiv").hide(3000); -----3秒渐变隐藏
$("div").toggle(3000);
$("#showdiv").slideDown(3000);
$("#showdiv").slideUp(3000);
$("#showdiv").fadeIn(3000);
$("#showdiv").fadeOut(3000);