jQuery click function and slideToggle

My problem is that when a user clicks on the `

` it opens the hidden `
` below it. That's great - works as expected. However when a user clicks back on the same `

` - it closes the `
` and reopens it instantly. I need the `
` to stay closed. I also need the remaining functionality to stay in place. This is my jQuery: $(document).ready(function() { $('div#winners-table div').hide(); $('div#winners-table h4').click(function(){ $('div#winners-table h4.open').each(function() { $(this).attr('class', 'closed'); $(this).siblings('div').slideUp(); }); $(this).toggleClass('open'); $(this).siblings('div').slideToggle(); }); }); **EDIT** This is my HTML:

...

  • ...

    ...
  • ...

    ...
  • ...

    ...
  • ...

    ...

Could you clarify your desired behavior concerning the closed class? Should every closed h4 have it, or just the last clicked h4?

以上就是jQuery click function and slideToggle的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » jQuery 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准

联系我们

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏