Javascript jQuery中的不一致行为取决于浏览器
我有我的jquery:Javascript jQuery中的不一致行为取决于浏览器,javascript,jquery,cross-browser,Javascript,Jquery,Cross Browser,我有我的jquery: $('.category-block').mouseover( function (e) { $(this).find('.b-expand').show(); }); $('.category-block').mouseout( function (e) { $(this).find('.b-expand').hide(); }); 和示例html:
$('.category-block').mouseover(
function (e) {
$(this).find('.b-expand').show();
});
$('.category-block').mouseout(
function (e) {
$(this).find('.b-expand').hide();
});
和示例html:
<div class="category-block" id="category-1">
<a href="#">Mod</a>
<div class="b-expand" id="block-expand-1">
TEST
</div>
</div>
它会起作用,当然,显示所有的b-expand并不仅仅是父项下的b-expand。因此,问题在于这个发现
没有不显示它的css属性。也没有抛出js错误。您可能想要的是:
$('.category-block').hover(function() {
$(this).find('.b-expand').show();
}, function() {
$(this).find('.b-expand').hide();
});
我刚刚在IE 8、FF 3.66、chrome 5.0.375和safari 4中进行了测试。它起作用了 你可能有一些脚本在页面的其他地方丢失了一个;在页面的某个地方 失踪;这样的错误并不总是以脚本错误的形式出现
您还可能丢失了一个或多个类似的html,这会扰乱页面结构 你所做的工作:如果你在Chrome中没有看到相同的行为,问题之外的东西会影响它。谢谢,我以前也尝试过这种技术,但它不起作用。更新了问题,它似乎与查找功能有关。更新了我的答案。如果find不起作用,我想这是你的html标记。你能发布整个页面的内容吗?
$('.category-block').hover(function() {
$(this).find('.b-expand').show();
}, function() {
$(this).find('.b-expand').hide();
});