Hi,
I have a Javascript function called changediv() that receives as a parameter
the
number that is the id of the element I want to change:
function changediv(divnu m) {
}
On the web page I have the following code:
<div id="div1" onclick="change div(1)">...</div>
This works OK.
But if I try to use the more modern way of associating an event with
an event handler, like,
function init() {
document.getEle mentById('div1' ).onclick=chang ediv(1);
}
window.onload=i nit;
it doesn't work because of the parameter. How can I pass a parameter
in this situation?
TIA
Paulo Almeida
I have a Javascript function called changediv() that receives as a parameter
the
number that is the id of the element I want to change:
function changediv(divnu m) {
}
On the web page I have the following code:
<div id="div1" onclick="change div(1)">...</div>
This works OK.
But if I try to use the more modern way of associating an event with
an event handler, like,
function init() {
document.getEle mentById('div1' ).onclick=chang ediv(1);
}
window.onload=i nit;
it doesn't work because of the parameter. How can I pass a parameter
in this situation?
TIA
Paulo Almeida
Comment