jquery点击.addClass问题
嗨,我一整天都遇到了麻烦,它几乎可以工作,但不完全,我需要相应的 p (#p-1 等)在单击缩略图后保持突出显示。我使用了图像滑块的插件,我对其进行了稍微自定义,并且 mouseover 和 mouseleave 事件工作正常,但单击事件似乎没有将类添加到目标段落。
jsfiddle 上的示例 http://jsfiddle.net/RVYnb/7/
相关的 jQuery 内联编写的例子。
这让我发疯,请帮忙!
Hi i have been having trouble all day with this, it almost works but not quite, i need the corresponding p (#p-1 etc) to stay highlighted once the thumb nail is clicked. I have used a Plug in for an image slider which i have customized slightly and the mouseover and mouseleave events are working fine but the click event doesn't appear to add the class to the target paragraph.
Example on jsfiddle http://jsfiddle.net/RVYnb/7/
The relevant jQuery is written inline on the example.
this is driving me crazy, please help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
错误出在图像滑块插件中。它还绑定到代码中的单击事件。
这是插件中的相关代码部分:
问题是最后的“return false”。它会停止传播到其他点击事件。
将代码更改为以下内容:
它应该可以工作。
The error is in the image slider plugin. It also binds to the click event in the code.
Here's the relevant code part in the plugin:
The problem is the "return false" at the end. It stopps the propagation to other click events.
Change the code to the following:
and it should work.
在我看来,根据“小提琴”,您的“点击”事件不适用于您的缩略图。它永远不会将“clicked”类添加到您的
.
我向其中添加了一个“警报”:
警报从未弹出。
It looks to me, according to the "fiddle", that your "click" event isn't working on your thumbnails. It's never adding the "clicked" class to your
.
I threw an "alert" into this:
and the alert never popped.