Adding a click event within a another function

This has been bugging me way too long. I am trying to create a click event within a function, which doesn’t seem to be working. Here is the basic layout: function init() { $('#a2').click(function() { //does some stuff. Works fine. $('#addDest').click(function() { //does more stuff. Works fine… if ($("#input2").is(':visible')) {alert("test");}; }); }); }; The page is always assuming #input2 is visible! Even though it is switching on and off. I check in Firebug and it is able to know the truth. However, when I click on #input2, the alert ALWAYS pops up! I could throw my problem part outside of the function. But that will create more problems – as I will have some undeclared variables when the document loads. I am thinking I made this the long way and maybe event handlers or clickevents are a solution for more. But I am not quite at that level of understanding yet. I know it is reading that problem area, as when the page loads. Is there an easier solution to this issue? I know I prolly need to learn more... Thanks a lot!!
So, every time you click on #a2, you want to reset the click event functionality on #addDest? Is that necessary?

以上就是Adding a click event within a another function的详细内容,更多请关注web前端其它相关文章!

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

评论 抢沙发

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

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

联系我们

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

支付宝扫一扫打赏

微信扫一扫打赏