Skip to content

Instantly share code, notes, and snippets.

@leobalter
Created May 26, 2011 23:28
Show Gist options
  • Save leobalter/994346 to your computer and use it in GitHub Desktop.
Save leobalter/994346 to your computer and use it in GitHub Desktop.
Solução para o exemplo contido em http://jsfiddle.net/YLhrP/
// exemplo em: http://jsfiddle.net/YLhrP/
function init() {
var dummy = [ 123, 234, 345, 456, 567, 678, 789, 890 ],
newDiv;
for ( var i in dummy ) {
newDiv = jQuery('<div id="newDiv_'+i+'">Clique Aqui!</div>');
newDiv.bind('click', (function(valor_de_i) {
return function(ev) {
jQuery(this).text(dummy[valor_de_i]);
};
})(i) );
newDiv.appendTo('#sandbox');
}
}
init();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment