Reputation: 45
I am writing a simple interactive widget that will eventually end up in an ibook.
It's a game where you drag and drop an item into the correct place, essentially matching animal sounds to the animals that make them.
I add my listeners in the HTML, like this for the target:
<div class="target_box_zebra"
ondrop="drop(event,'zebra')"
ondragexit="dragLeave(event,'zebra')"
id="zebra_target"
ondragenter="drag_enter(event,'zebra')"
ondragover="allowDrop(event,'zebra_target')"
ondragleave="drag_leave(event,'zebra')">
</div>
Once the correct target has been found (simple if
statement) I want to remove all the listeners so that it is just an the plane div with its default background image.
I tried unbind but it didn't work. Any suggestions or guidance would be super.
Upvotes: 2
Views: 116
Reputation: 8646
Unbind only works, if you don't use inline handlers.
Check out https://developer.mozilla.org/en-US/docs/DOM/element.addEventListener.
Upvotes: 1