wrynn
asked on
attaching and detaching onclick=somefunction(this) to a div dynamically
how can i attach onclick="someFunction(this )" to a div through javascript? how can i de attach it? thanks
document.getElementById('d ivID').onc lick = someFunction();
another example:
var el = document.getElementById('f oo');
el.onclick = showPopup;
//NOTE: showPopup();
//or showPopup(param);
//will NOT work here.
//Must be a reference to a function,
//not a function call.
function showPopup() {
var popup = window.open(this.href, "popup", "height=800,width=600");
popup.focus();
return false;
}
var el = document.getElementById('f
el.onclick = showPopup;
//NOTE: showPopup();
//or showPopup(param);
//will NOT work here.
//Must be a reference to a function,
//not a function call.
function showPopup() {
var popup = window.open(this.href, "popup", "height=800,width=600");
popup.focus();
return false;
}
ASKER
but how can i do el.onclick = showPopup(this)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.