在 jQuery 中使用 .not 函数和 .hover
我正在尝试使用以下代码块,但不起作用。我需要使用悬停功能,但如果 div 有类 myclass,则不想显示样式 display: none
:
jQuery('.image').not('.myclass').hover( function()
{
jQuery(this).find('.arrow').show();
}, function()
{
jQuery(this).find('.arrow').hide();
});
I'm trying to use the following block of code, but is not working. I need to use the hover function, but do not want to show the style display: none
if the div has a class myclass:
jQuery('.image').not('.myclass').hover( function()
{
jQuery(this).find('.arrow').show();
}, function()
{
jQuery(this).find('.arrow').hide();
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以考虑使用
if 语句
,而不是not
。类似示例: http://jsfiddle.net/ccB7K/2/
Instead of
not
, you might consider anif statement
. Something likeExample: http://jsfiddle.net/ccB7K/2/
不要使用 .not,而是使用 JQuery 的 not CSS 样式选择器。
执行这里。 http://jsfiddle.net/CJp4A/
Instead of using .not, use JQuery's not CSS style selector instead.
Implementation here. http://jsfiddle.net/CJp4A/
您可以尝试这个
http://api.jquery.com/not-selector/
You can try this
http://api.jquery.com/not-selector/