I\'m learning JavaScript and I\'ve not that much experience.
But I\'m making a HTML table and I want to add in every table cell ( if you have access to jquery, do this You may try this too (using event delegation) EXAMPLE. Using jQuery EXAMPLE.) a onClick event.
$('#1 td').click(function(){
});
window.onload = function(){
document.getElementById('tbl1').onclick = function(e){
var e = e || window.event;
var target = e.target || e.srcElement;
if(target.tagName.toLowerCase() == "td") {
alert(target.innerHTML);
}
};
};
$(function(){
$('#tbl1').on('click', 'td', function(){
alert($(this).html());
});
});