jquery 中 this 的范围
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!!! }
扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄

更多精彩