How to not execute a jQuery function on a certain condition

I have a 2-level nested
container (see below). When I click anywhere inside the .summary
, the details are revealed as they should be. When I check the checkbox, I do not want the details to be revealed. So I tried throwing in some globals vars to control the slideToggle(). It works in IE but not in Firefox. Is there anyway to prevent the slideToggle() from executing whenever you check the box? It should execute at all other times. ***** HTML *****
Data 1
Data 2
Detailed information
***** JavaScript ***** $(document).ready(function(){ var boxChecked = 'N'; $('input:checkbox').change(function() { $(this).closest('div.col_5').html('Yes'); boxChecked = 'Y'; }); $('.summary').click(function(e){ if (boxChecked == 'N') $(this).next('.details').slideToggle('slow'); boxChecked = 'N'; }); }); It's almost as though .click() takes execution precedence over .change() in Firefox.

以上就是How to not execute a jQuery function on a certain condition的详细内容,更多请关注web前端其它相关文章!

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

评论 抢沙发

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

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

联系我们

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

支付宝扫一扫打赏

微信扫一扫打赏