dimanche 7 février 2016

Creating multiple event listeners using a loop

Trying to create multiple listeners with a loop. How to make it work?

var buttons = ['one', 'two', 'tree'];
$.each(keys, function(key, value) {
    $(value).click(function() {
        // do something
    });
});

Also, is there a shortcut to not writing key, value when I only need the value?




Aucun commentaire:

Enregistrer un commentaire