$("li:first-child").css("background-color", "green"); 所有第1个元素的集合
$("li:first") 第1个元素
$("li:eq(2)") 第3个元素
$("li:first") 第1个元素
$("li:eq(2)") 第3个元素
2015-08-20
$("li[title*='果']").css("background-color", "green"); 注意别忘记* 也别有空格在title和*之间否则不通过
2015-08-20
$("li[title='蔬菜']").css("background-color", "green");
2015-08-20
获取标签名: $("li:has('p')");
获取文本内容 $("li:contains('文字')")
获取文本内容 $("li:contains('文字')")
2015-08-20
$("li:contains('jQuery')").css("background", "green"); 忘记“”
2015-08-20
插件使用:(function($){$.extend({"ChangeBgColor":function(obj){obj.hover(function(){obj.addClass("focus");},function(){obj.removeClass("focus");});} });})(jQuery);
$(function(){
$("li").each(function(){
$.ChangeBgColor($(this));
})
});
$(function(){
$("li").each(function(){
$.ChangeBgColor($(this));
})
});
2015-08-20
$("span").empty()选中span 清除span内容。 empty不需要加参数
2015-08-20
参数speed设置隐藏或显示时的速度值,可为“slow”、“fast”或毫秒数值,可选项参数callback为隐藏或显示动作执行完成后调用的函数名。
2015-08-20
非插件:$(function(){$("ul li").each(function(){$(this).bind("mouseover",function(){$(this).addClass("focus");
});
$(this).bind("mouseout",function(){
$(this).removeClass("focus");
});
}) ;
});
});
$(this).bind("mouseout",function(){
$(this).removeClass("focus");
});
}) ;
});
2015-08-20