jQuery bind event does not work at all

后端 未结 3 1118
栀梦
栀梦 2021-01-16 06:41

I did everything I could to make it happen, but without success.

The problem is that I create an element on runtime then bind a function to the element like the fo

3条回答
  •  旧时难觅i
    2021-01-16 07:16

    try this

    $(document).ready(function(){
    
        $('.rem').click(function(){
            $('runtime').bind('click',func_name).appendTo("body");
        });
    });//End of doc
    function func_name(){
        alert('I got it!');
    }
    

    Since you are binding the object before it has been created, you are not getting the desired result.

提交回复
热议问题