<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html;charsrt=utf-8"> <title>制作我的第一个网页</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循环的包装迭代器 each通过回调的方式处理,并且会有2个固定的实参,索引与元素 each回调方法中的this指向当前迭代的dom元素 $("li").each(function(index, element) { index 索引 0,1 element是对应的li节点 li,li this 指向的是li })
2016-11-170个赞