zhaoyu2288 发表于 2013-1-29 11:43:55

JQuery常用函数(2)--操作对象以及AJAX

AJAX请求
//参数1::请求url   参数2:查询字符串    参数3:回调时的处理函数//注意!:参数2也可以放一个对象或json//注意!:这个参数data,就是ajax请求响应的数据$.get("getPageModel.action","id=1&name=zl",function(data){   alert(data);});//PS:$.post用法一样区别在于请求方式

处理对象
1: //处理list和数组var array = ["11","22","33","44","55"];   //定义数组//参数一:数组   参数二:对数组的操作方法$.each( array, function(num,value){//document.write(text);在页面上输出text为内容,可以为标记 如"<hr/>"         //num:下标(会自动生成-从0开始)            //value:遍历的数组的值document.write("序号"+num+"-值"+value+"<br/>");})2: //处理map集合和对象var o = {one:1,two:2,three:3,four:4,five:5};//创建对象或Map-用{}//参数一:数组   参数二:对数组的操作方法$.each(o, function(property,value){         //property为key   value为值         document.write("属性"+property+"-值"+value+"<br/>");});

显示和隐藏效果
1://标记的 显示-show()   隐藏-hide()$(function(){//绑定 事件$("button:eq(0)").bind("click",function(){$("p").hide();//隐藏})$("button:eq(1)").bind("click",function(){$("p").show();//显示})});2://标记的 收起-show(time) 展开-hide(time)//time为毫秒3000为 3秒$(function(){//绑定 事件$("button:eq(0)").bind("click",function(){$("p").hide(3000);//逐渐收起})$("button:eq(1)").bind("click",function(){$("p").show(3000);//逐渐展开})});3://原地的 逐渐直接显示-fadeIn(time)   逐渐直接隐藏-fadeOut(time) //time为毫秒3000为 3秒$(function(){//绑定 事件$("button:eq(0)").bind("click",function(){$("div").fadeOut(3000);//逐渐隐藏})$("button:eq(1)").bind("click",function(){$("div").fadeIn(3000);//逐渐显示})});4://拉窗帘效果逐渐拉上去-slideUp(time)   逐渐放下来slideDown(time)//time为毫秒   3000为 3秒$(function(){//绑定 事件$("button:eq(0)").bind("click",function(){$("img").slideUp(3000);//逐渐拉上去})$("button:eq(1)").bind("click",function(){$("img").slideDown(3000);//逐渐放下来})});
页: [1]
查看完整版本: JQuery常用函数(2)--操作对象以及AJAX