jquery 设计思想
1. jQuery 版本区别
- jQuery 1.0可以兼容到ie8以下
- jQuery2.0 只兼容ie8以上
- jQuery 3.0
2. jQ设计思想
- 1.模拟css选择网页元素
- 2.独有表达式
- 3.方法式函数
- 4.链式操作
- 5.与原生js可以共存,不能混用
3.实例
$(function(){
//#id
$("#div1").css("backgroundColor","red")
//.class
$(".box").css("backgroundColor","black")
// tagName
$("ul li").css("backgroundColor","black")
$("[name=hello]").css("backgroundColor","black")
//表达式的写法
$("li:first").css("backgroundColor","red")
$("li:last").css("backgroundColor","red")
//高级写法
$("li:even").css("backgroundColor","red")
$("li:odd").css("backgroundColor","red")
$("li:eq(1)").css("backgroundColor","red")
$("li.box").css("backgroundColor","red")
$("li").filter(".box").css("backgroundColor","red")
})
关注微信公众号前端凌影,一起学习吧!