var img = document.createElement('img'); img.setAttribute('width', '24'); img.setAttribute('height', '24'); td4.setAttribute('style','width:3%'); td4.setAttribute('align','center'); (function(id) { img.onclick = function(e) { e.preventDefault(); e.stopPropagation(); // now it will alert the id (what is the i of the for-loop): if( img.attr('src')== "images/correct-icon.png") alert(id); }; }(i));
if(serviceAlertPresent[i].firstChild.nodeValue == 'false'||otherAlertPresent[i].firstChild.nodeValue == 'false') { img.src='images/correct-icon.png'; //td4.innerHTML = "<img src=\"images/correct-icon.png\" width=\"20\" height=\"20\" />"; td5.innerHTML=""; } else { img.src='images/error-msg.png'; //td4.innerHTML = "<img src=\"images/error-msg.png\" width=\"20\" height=\"20\" />"; td5.innerHTML=expDepart[i].firstChild.nodeValue ; } td4.appendChild(img);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)