Last active
August 26, 2015 16:30
-
-
Save BrechtBonte/73da4c486dbe6e1d71e1 to your computer and use it in GitHub Desktop.
some random js class containing DOM
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Circle() | |
{ | |
var _circle; | |
function init() | |
{ | |
_circle = $('<div class="circle"></div>'); | |
$('body').append(_circle); | |
} | |
function getDOM() | |
{ | |
return _circle; | |
} | |
return { | |
init: init, | |
getDOM: getDOM | |
}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="/js/circle.js"></script> | |
<script type="application/javascript"> | |
$(function() { | |
var circles = []; | |
for (var i = 0; i < 10; i++) { | |
var circle = new Circle(); | |
circle.init(); | |
circles.push(circle); | |
} | |
$.each(circles, function(i) { | |
this.getDOM().on('click', function() { | |
alert('much click: ' + i); | |
}); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment