[RESOLVED]How to pass an array as parameter to custom event?

<script>
        $(function () {
            $('div').bind('test', function (event, data) {
                console.log(data);
            });
            $('div').trigger('test', [1, 2, 3]);
        })
    </script>
    <div></div>

the result is a single int 1,

however, I want the result is entire array [1, 2, 3]

One workaround is set array to a property of an object. Is there a better way?

ok, find solution myself

use

$('div').trigger('test', new Array( [1, 2, 3]));

Leave a Reply