这是我的小提琴
除了鼠标、鼠标保存、点击功能(.item)之外,几乎完全正常工作--并且需要点击鼠标才能重新开始工作?为什么-这是我的密码-
$(document).ready(function () {
$('.timelineTile').click(function (evt) {
evt.stopPropagation();
$('.timelineTile').not(this).removeClass('clicked').find('.pull_down_content').height(0);
$(this).toggleClass('clicked');
if(!$('.timelineTile').hasClass("clicked")){
$(this).children('.pull_down_content').height(0);
}
}); });
$(document).click(function () {
$('.timelineTile').removeClass('clicked');
$('.pull_down_content').height(0);
$('.inner').stop().css({'display': 'none'}, 300);
});
$(document).ready(function () {
$('.timelineTile').children('.item').on('mouseenter mouseleave click', function(e) { e.stopPropagation();
if ($(this).parent('.timelineTile').hasClass("clicked")) {
if (!$(this).data('clicked')) {
var Height = e.type==='mouseenter' ? '90px' : e.type==='click' ? '250px' : '0px';
$(this).siblings('.pull_down_content').stop().animate({'height': Height}, 300);
$(this).siblings('.pull_down_content').children('.inner').css({'display': 'block'}, 300);
if (e.type==='click') $(this).data('clicked', true);
}else{
if (e.type==='click') {
$(this).data('clicked', false);
$(this).siblings('.pull_down_content').stop().animate({'height': '0px'}, 300);
$(this).siblings('.pull_down_content').children('.inner').css({'display': 'none'}, 300);
}
}
}
});
});我不确定这和这有什么关系吗?
if(!$('.timelineTile').hasClass("clicked")){
$(this).children('.pull_down_content').height(0);
} 发布于 2014-10-15 16:17:53
试着替换
$('.timelineTile').not(this).removeClass('clicked').find('.pull_down_content').height(0); 有了这个
$('.timelineTile').not(this).removeClass('clicked').find('.pull_down_content').height(0).end().find('.item').data('clicked',false); 发布于 2014-10-15 14:07:59
当元素不存在时,您可能会尝试附加事件(例如,如果它们将由脚本动态添加)。
使用更现代的“on”,而不是“click”等。
$(wrapper).on('click', 'element', function() { ... });小象:
...
<div class="wrapper">
<span class="link">Click me</span>
</div>
...
$('.wrapper').on('click', '.link', function() { ... });此变体为所有元素添加事件,即使它们是动态添加的。
https://stackoverflow.com/questions/26384341
复制相似问题