Indeed this
refers to the button you have created but that would require everything to be present on the DOM element beforehand.
If you want more information a closure would be nicer solution:
(function ($) {
var name = 'foo',
someOtherData = { foo: 'bar' },
button = $('<button>', {
'text': 'yaay',
'click': function () {
// i can use name, button in here
}
);
}(jQuery));
Of course the self executing function can be rewritten with arguments which you can pass to your button. It all depends how much information you need when it's clicked.