Here is an example of how to set up event listeners:
document.getElementById("A").addEventListener("change", function (e) {
// do something when A changes
}, false)
document.getElementById("B").addEventListener("click", function (e) {
// do something when B is clicked
}, false)
I have two queries:
- How can I write this in the event handler version?
- How should I invoke it?
This is a suggested structure:
<script type="text/javascript">
function [function for question 1]
{
// do something when A changes
}
function [function for question 2]
{
// do something when B is clicked
}
</script>
<div id="A" change="[function for question 2]"></div>
<div id="B" click="[function for question 2]"></div>