好的。我有以下脚本:
$('#exhibitions .item.plain').toggle(
function() {
$(this).css({
'height': '302px',
'z-index': '10',
'background': '#3F94AB'
});
$(this).find('p.title').css('color', '#E6E6E6');
$container.isotope('reLayout');
},
function() {
$(this).css({
'height': "130px",
'z-index': '0',
'background': '#CCC'
});
$(this).find('p.title').css('color', '#353334');
$container.isotope('reLayout');
});
而 .item.plain
被赋予带有嵌套 anchor
的 div。当我点击它时,很明显 )) toggle()
被触发了。
<div class="item plain">
<!-- some stuff -->
<a href="url I want to go"></a>
</div>
我该如何解决这个问题?
谢谢!
最佳答案
如果我很清楚您不想在单击链接时切换元素 .item.plain
,那么请停止以这种方式传播事件
$('#exhibitions .item.plain a').on('click', function(evt) {
evt.stopPropagation();
});
关于javascript - 不能使用嵌套 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10737888/