jquery 中的 this
button 通常会存在 onclick;// input[type='file'] 会存在 onchange 事件
eg: onclick = " deletePic(this) "
这里一定要注意。 this 不能省略。
如果省略;
funtion deletePic(){
$(this).parent() == window //显然。这个 this 并不是按钮本身了。
}
所以。一定一定要在方法中写:
function deletePic( obj ) {
$(obj).parent(); ---// 这里的 obj 就是你 button 中传入的对象。如果写的是 onclick= "deletePic(this)" 则 obj == this!!!
}