Something on this blog uses jQuery, because I certainly didn't load it. Maybe I'll inspect the source and see if I can spot where it comes from. I wish underscore.js was here as well though, I love that library. Although it isn't too important for a small test like this. Underscore is more useful at work, where we deal with tables and lists of dicts and lists and objects and so on.
$(document).ready(function() {
var lbls = ['btn', 'hei', 'lol', 'lel', ':3', ';)', 'rofl'];
$('#testBtn').on('click', function(ev) {
var curr = parseInt($(ev.target).attr('data-lbl-id'), 10);
var next = curr < lbls.length - 1 ? curr + 1 : 0;
$(ev.target).html(lbls[next]);
$(ev.target).attr('data-lbl-id', next);
alert('you pressed the ' + lbls[curr] + ' button');
});
});
No comments:
Post a Comment