简体   繁体   中英

jQuery - TypeError: “”.match is not a function

(function( $ ) {

    $(function() {

        $( '.AddRow' ).delegate( 'click', function() {
            var $this = $( this ),
                $tbody = $this.parents( '.tbody' );
            $tbody.find( 'td:nth-child(-2)' ).css( 'background', 'red' );
        });

    });

})( jQuery );

I'm getting the following error :

Timestamp: 07/08/2013 21:02:49
Error: TypeError: "".match is not a function
Source File: file:///C:/Program%20Files/Wamp/www/kbd-creator/v5/jquery-1.10.2.min.js
Line: 5

I tried changing .delegate to .on and the error doesn't appear anymore. Am i doing something wrong with .delegate ?

You're missing a parameter to .delegate() . Probably you should use .on() anyway, though note that if you call it with just 2 parameters it's not going to be a delegated handler setup.

See the documentation .

.delegate() should be called on a container element. It takes three parameters: a selector to listen for events on, an event name, and a handler.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM