$(function(){ var $content = $(this).next(); $("#para h5.head").bind("mouseover",function(){ $content.show(); //$(this).next().show(); }).bind("mouseout",function(){ $content.hide(); //$(this).next().hide(); })});在执行的时候,变量 $content 访问不到,如果按照注释编辑代码反而可以使用。请问是作用域的问题吗?还是哪里出错了,还是不可以这么声明。谢谢。
3 回答

慕的地10843
TA贡献1785条经验 获得超8个赞
你在bind
外面声明时,this
指向的是window
而你在bind
里面使用$(this)
, 这里的this
指向的是$("#para h5.head")
这个对象,所以执行正确。
但是你用$content
时对象是指window
而不是$("#para h5.head")
,所以访问不到。
能明白?
添加回答
举报
0/150
提交
取消