javascript not working on dynamically added tabs

后端 未结 4 745
执笔经年
执笔经年 2021-01-26 06:01

I am facing a strange bug at the moment, involving javascript. I have used jquery ui tabs to dynamically add and remove tabs in my website, the content of the tab contains two b

4条回答
  •  野性不改
    2021-01-26 06:29

    use on delegated events...

    $(document).on("mouseenter", "#butt", function () {
      $(this).css("visibility","hidden");
    });
    
    $(document).on("mouseleave", "#butt", function () {
      $(this).css("visibility","visible");
    });
    

    you can read through this post if you want to know more about on direct and delegated event

    it is better if you delegate it to closest static element that is present in the document rather than to document or body for better performance

提交回复
热议问题