=========2016年11月24日 星期四 09:36:53 =========
循环:
原生: for(var i = 0; i<10;i++){}
jquery: 没有
循环一些有意义的事情
循环处理一组元素
$('li') $('.on')
[] 数组
{} JSON
$.each(要循环的东西,function(index,element){
});
$.each({name1:v1,name2,v2},function(i,v){
i -- json中的 name
v -- json中的 value
});
关于each循环,另外一种写法:
$('li').each(function(i,v){
//每一个做处理
});
=========2016年11月24日 星期四 10:11:41 =========
字符串:
charAt()
substring split indexOf lastIndexOf toLowerCase......
原生:trim() -- 去除空格,只去除首尾的空格
jQuery: $.trim(str2) -- 去除空格,只去除首尾的空格
=========2016年11月24日 星期四 10:21:54 =========
find
=========2016年11月24日 星期四 10:40:50 =========
ajax:
$.ajax();
$.get(); //发get请求
$.post(); //发post请求
$.getJSON();
=========2016年11月24日 星期四 11:04:43 =========
问题:
1)getJSON :
请求一个本地的txt文件 , {} []
2)$.each($('li'),function(i,v){
document.write($('li').eq(i).html());
});
3) 微博服务器接口问题 -- bug
=========2016年11月24日 星期四 11:07:15 =========
jquery插件:
http://jqueryui.com/
自己想写插件:
$.fn.名字 = function(){
}
this -- 插件中的this 就是jquery对象 ,不再是一般情况下的原生对象
批量写插件:
$.fn.extend({
toRed:function(){},..
});
=========2016年11月24日 星期四 12:01:06 =========
* jquery 1.4 版本以后,JSON中不允许使用单引号
* document.write 以后,页面上就没东西了,不要再试图获取元素了
例子: