click() jquery function not available on new divs

前端 未结 4 729
说谎
说谎 2021-01-19 05:44

During the running of my website i create new divs using jquery with class \"a\". I have defined a click() function for \"a\" class as follows:

$(document).r         


        
4条回答
  •  伪装坚强ぢ
    2021-01-19 06:02

    Try using the .live() function which should also apply for newly inserted DOM elements that match your selector:

    $(document).ready(function() {
        $(".a").live('click', function(){
            $(".a").hide();
        });
    });
    

提交回复
热议问题