jQuery bind event does not work at all

后端 未结 3 1091
栀梦
栀梦 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条回答
  •  臣服心动
    2021-01-16 07:12

    You don't want to run the function at the point in the code, so remove the ():

    $('#runtime').bind('click', func_name);
    

    If you're using jQuery 1.7+, though, you should either use .on():

    $('#runtime').on('click', func_name);
    

    or use a .click() handler directly:

    $('#runtime').click(func_name);
    

提交回复
热议问题