I have created a table at design time and adding rows to it at runtime.
I want to attach a mouseover event to each row of first column which displays the respective tooltip.
for(ctr=0;ctr<noOfRows;ctr++){
var myTable=document.getElementById("myTable");
var newRow = myTable.insertRow(1);
var cell0 = newRow.insertCell(0);
cell0.innerHTML="Cell Data"+"<div class='hiddenToolTip' id='tip"+ctr+"'>"+tooltip+"</div>";
cell0.onmouseover=function(){
$("#tip"+ctr).show('blind',500);
};
cell0.onmouseout=function(){
$("#tip"+ctr).hide();
};
}
The problem is that the ‘ctr’ variable is always coming as the highest value inside ‘onmouseover’ and ‘onmouseout’ function.
just pass this in function argument and get value of ctrl as below using id of the element
Check this example for this : Javascript: Adding OnMouseOver And OnMouseOut Using DOM