On Window
's load, every DD
element inside Quote_App
should have an onCLick
event appended that triggers the function Lorem
, however, Lorem
returns the nodeName
and Id
of the last element in the For
statement rather than that of the element that trigged the function. I would want Lorem
to return the nodeName
and Id
of the element that triggered the function.
function Lorem(Control){
/* this.Control=Control; */
this.Amet=function(){
return Control.nodeName+"\n"+Control.id;
};
};
function Event(Mode,Function,Event,Element,Capture_or_Bubble){
if(Mode.toLowerCase()!="remove"){
if(Element.addEventListener){
if(!Capture_or_Bubble){
Capture_or_Bubble=false;
}else{
if(Capture_or_Bubble.toLowerCase()!="true"){
Capture_or_Bubble=false;
}else{
Capture_or_Bubble=true;
};
};
Element.addEventListener(Event,Function,Capture_or_Bubble);
}else{
Element.attachEvent("on"+Event,Function);
};
};
};
function Controls(){
var Controls=document.getElementById("Quote_App").getElementsByTagName("dd");
for(var i=0;i<Controls.length;i++){
var Control=Controls[i];
Event("add",function(){
var lorem=new Lorem(Control);
lorem.Control=Control;
alert(lorem.Amet());
},"click",Controls[i]);
};
};
Event("add",Controls,"load",window);
Currently you click on any DD
element Lorem
always returns the nodeName
and Id
of the last DD
element.
Lorem
should return the nodeName
and Id
of the Control
(Control[i]
) that triggered Lorem
.
How do I go about making this happen?
Thank you!