capture click event of submit button jquery

后端 未结 6 1936

I am trying to get the click event of a submit button on my form...



        
6条回答
  •  佛祖请我去吃肉
    2021-02-06 01:00

    You have to encase your code in a function..

    $('#submitDemo').click(function(){
        alert("work darn it!!!!!!!!!!!!!!!!!!!!!!!!!")
        //$("#list").block({ message: '' })
    });
    

    But it is always a good practice to bind the event using on so that it attaches the event handler to the element when that is available.. So

    $('#submitDemo').on('click',function(){
        alert("work darn it!!!!!!!!!!!!!!!!!!!!!!!!!")
        //$("#list").block({ message: '' })
    });
    

提交回复
热议问题