jQuery 'if .change() or .keyup()'

后端 未结 7 680
说谎
说谎 2020-12-13 05:26

Using jQuery i would like to run a function when either .change() or .keyup() are raised.

Something like this.

if ( jQuery(         


        
7条回答
  •  执笔经年
    2020-12-13 05:52

    You could subscribe for the change and keyup events:

    $(function() {
        $(':input').change(myFunction).keyup(myFunction);
    });
    

    where myFunction is the function you would like executed:

    function myFunction() {
        alert( 'something happened!' );
    }
    

提交回复
热议问题