SO Help: Refreshing the Div not working when link is inside
http://stackoverflow.com/questions/20080257/refreshing-the-div-not-working-when-link-is-inside/20080286#answer-20080286
by SpYk3
HTML
<!--
Adding events to dynamic content is as simple as:
$(document).on('event', 'selector', function(e) { /* callback work here */ });
-->
CSS
button { cursor: pointer; font-size: 20px; font-weight: bold; padding: 1em; text-shadow: 0 0 0.2em #8F7; }
JavaScript
var txts = [ 'Push Me!', 'Not Again!?', 'WTF?', 'WWJD?', 'Hello', 'World', 'DollY!' ]
function createButton() {
$('button').remove();
var txt = txts[Math.floor((Math.random()*txts.length))],
clr = '#'+Math.floor(Math.random()*16777215).toString(16);
$('<button />', { style: 'background-color: '+clr+'; display: none;', text: txt }).appendTo($('body')).fadeIn('slow');
}
$(function() {
$(document).on('click', 'button', function(e) {
$(this).fadeOut('slow', createButton);
});
createButton();
})