$(‘body > div‘).css("background","#bbffaa"); //和children()方法是等价的,父子关系,和parent()方法是对立的
$(‘body‘).children(‘div‘).css("background","#bbffaa"); 和$(‘body > div‘)是等价的
$(‘body‘).children().css("background","#bbffaa"); //没有搜索条件的时候返回元素的所有子节点
$(‘body‘).children(‘#abc‘).css("background","#bbffaa"); //查找不存在的元素返回空
$(‘body‘).children(‘#two-two‘).css("background","#bbffaa"); //查找唯一的元素就返回该元素
$(‘.one‘).children().css("background","#bbffaa"); //class寻找所有的子节点
$(‘.one‘).children(‘#one-one‘).css("background","#bbffaa"); //class寻找唯一元素
$(‘.one‘).children(‘.mini‘).css("background","#bbffaa"); //class寻找class
时间: 2024-10-13 04:32:51