Jquery 在触发器后运行.slideDown();
在页面加载时,我需要模拟对标签的单击,然后,当它被单击时,我想向下滑动();#评论者信息 所以我要找的是这样的东西:Jquery 在触发器后运行.slideDown();,jquery,triggers,Jquery,Triggers,在页面加载时,我需要模拟对标签的单击,然后,当它被单击时,我想向下滑动();#评论者信息 所以我要找的是这样的东西: if ($(this).attr('id') == 'true') { $(this).trigger("click", function() { $(this).closest('form').find('#commenter-info').slideDown(); }
if ($(this).attr('id') == 'true') {
$(this).trigger("click", function() {
$(this).closest('form').find('#commenter-info').slideDown();
});
}
如果的id为“true”,请单击该链接,然后执行slideDown()
问题是“#评论者信息”被添加到点击事件中,而不出现在页面加载中。您必须分两步进行
if ($(this).attr('id') == 'true') {
// First set up the listener :
$(this).bind("click", function() {
$(this).closest('form').find('#commenter-info').slideDown();
});
// Then, fire the click event
$(this).click();
}
$(this).attr('id')将为您提供元素id。问题是什么。?请创建一个JSFIDLE或提供更多代码。我认为问题在于此表单是在单击事件中动态加载的。。因此,它在点击之后才会出现。有什么想法吗?创建表单后会启动哪个活动?单击,表单将被添加。。当表单被添加时,我想运行“$(this).closest('form').find('#commenter info').slideDown();”你不能监听dom更新,因为表单是在点击后生成的,你也不能监听它。你可以尝试插入表单generation或setTimeout(但地球会自行碰撞)。你能告诉我表格是怎么生成的吗?