jQuery中this 和 $(this)
var node = $('#id'); node.click(function(){ this.css('display','block'); //报错 this是一个html元素,不是jquery对象,因此this不能调用jquery的css()方法 $(this).css(); //正确 $(this)是一个jquery对象,不是html元素,可以用css()方法 this.style.display = 'block'; //正确 this是一个html元素,不是jquery对象,因此this不能调用jquery的css()方法,但是可以用javascript来更改style属性 });
来自:http://t.zoukankan.com/mabelstyle-p-3782073.html

浙公网安备 33010602011771号