$(function(){//遍历获取的input元素对象数组,绑定click事件
var len = $("input[type='file']").length;for(var i = 0; i < len; i++){
$("input[type='file']").eq(i).click(function(){
$(this).next().val("");
$(this).next().hide();
$(this).css("width","200px");
})
}
}
jQuery获取:
jQuery.parent(expr),找父亲节点,可以传入expr进行过滤,比如$("span").parent()或者$("span").parent(".class")
jQuery.parents(expr),类似于jQuery.parents(expr),但是是查找所有祖先元素,不限于父元素
jQuery.children(expr),返回所有子节点,这个方法只会返回直接的孩子节点,不会返回所有的子孙节点
jQuery.contents(),返回下面的所有内容,包括节点和文本。这个方法和children()的区别就在于,包括空白文本,也会被作为一个jQuery对象返回,children()则只会返回节点
jQuery.prev(),返回上一个兄弟节点,不是所有的兄弟