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

后端 未结 7 671
说谎
说谎 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 06:08

    Write a single function and call it for both of them.

    function yourHandler(e){
        alert( 'something happened!' );        
    }
    jQuery(':input').change(yourHandler).keyup(yourHandler);
    

    The change() and keyup() event registration functions return the original set, so they can be chained.

    0 讨论(0)
提交回复
热议问题