<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html;charsrt=utf-8"> <title>制作我的第一個網(wǎng)頁</title> </head> <body> <h1>hello world</h1> </body> </html>
2016-11-150個贊
$("button:first").click(function() { $(".item-1").next().css("border","1px solid red"); })
2016-11-170個贊
prev()中添加選擇器, 是在這些緊鄰的上一個元素集合中做出進一步篩選, 比如: eq(1), first, last, :contains("3"), has('p'),添加符合你需求的選擇器來篩選, 這和next()是一樣的,只是二者的功能不一樣
2016-11-170個贊
each是一個for循環(huán)的包裝迭代器 each通過回調(diào)的方式處理,并且會有2個固定的實參,索引與元素 each回調(diào)方法中的this指向當前迭代的dom元素 $("li").each(function(index, element) { index 索引 0,1 element是對應(yīng)的li節(jié)點 li,li this 指向的是li })
2016-11-170個贊