I'm working on a simple game and struggling with how to bind my DOM objects to the JS objects that spawn them. This used to be very easy back in the days of Flash - the object and it's visual representation were one and same! What's the best way to do this with JS/HTML? Here's a stripped down example of what I'm trying to do:
<body>
<div id="pond"></div>
</body>
<script>
function fish() {
this.genotype = 'GATTACA';
this.phenotype = '<div class="fish" onclick=reveal()></div>';
}
shark = new fish();
$(shark.phenotype).appendTo("#pond");
function reveal() {
alert(this.genotype);
}
</script>
shark.boundElement = $(shark.phenotype).appendTo("#pond");... depends on what jquery appendTo returns I guess