1
我在.hover()
函数中使用.index()
时遇到了一些问题。谢谢你的帮助。在悬停中使用.index()
$("#myUL li").hover(
function() {
//this logs a li element as it should
$(this).log();
//this reports that it's not a valid function, why?
$("#myUL").index(this).log();
//when i do it this way...
var foo = $("#myUL").index(this);
//this returns -1. Why can't it find the li?
$(foo).log();
},
function() {
}
);
如果它的确与众不同,这是我使用的.log()
函数的代码:
jQuery.fn.log = function (msg) {
console.log("%s: %o", msg, this);
return this;
};
:编辑:每评论,下面是HTML:
<ul id="myUL">
<li>
<div><img src="images/img1.jpg"/></div>
</li>
<li>
<div><img src="images/img2.jpg"/></div>
</li>
<li>
<div><img src="images/img3.jpg"/></div>
</li>
</ul>
您可以添加HTML PLZ? – jantimon 2009-10-28 17:05:31
肯定Ghommey - 谢谢你的回应。我已经添加了html - 查看我的编辑 “:编辑:根据评论,这里是html:” – thinksketchdesign 2009-11-11 19:09:55