美文网首页
动态添加控件js失效问题

动态添加控件js失效问题

作者: 在一颗大大大榕树下 | 来源:发表于2019-06-03 13:50 被阅读0次

使用delegate或者on解决问题。

 $(".project-details").on('.project-details dl','click',function () {
                   if($(this).find("dd").css('display') == 'none'){
                       $(this).addClass("am-active")
                       $(this).find("dd").css('display','block')
                   }else{
                       $(this).removeClass("am-active")
                       $(this).find("dd").css('display','none')
                   }
                })

相关文章

网友评论

      本文标题:动态添加控件js失效问题

      本文链接:https://www.haomeiwen.com/subject/morcxctx.html