Search
 
SCRIPT & CODE EXAMPLE
 

HTML

Javascript to select td element that was clicked in a table

var tbl = document.getElementById("tableb");
    if (tbl != null) {
      for (var i = 0; i < tbl.rows.length; i++) {
        for (var j = 0; j < tbl.rows[i].cells.length; j++)
          tbl.rows[i].cells[j].onclick = function () { getval(this); };
      }
    }
    function getval(cel) {
      alert(cel.innerHTML);
      cel.setAttribute('style', 'background-color:red');
    }
Comment

PREVIOUS NEXT
Code Example
Html :: emmet multiple tags 
Html :: html label tag 
Html :: html select required message 
Html :: mozilla date input 
Html :: html table column filter dropdown 
Html :: puppeteer html custom attribute 
Html :: on click drop down bootstrao 
Html :: excel auto tage with date and time 
Html :: copy to cllipboard the html element 
Html :: HTML - The Head Element 
Html :: best slider library 
Html :: python download html as text 
Html :: html table resize columns 
Html :: bootstrap starter template 
Html :: carousel 
Html :: detailed list html 
Html :: aside html 
Html :: empty elements in html 
Html :: static html template 
Html :: boostrap navbar 
Html :: Using SVG as an <img 
Html :: create a close x button in html 
Html :: editor html gratis online 
Html :: negrit html 
Html :: bootstap loading 
Html :: Testing the dom api 
Html :: justify content css 
Html :: bootstrap 5 image slider with ngFor 
Html :: how to change the postion of text in html 
Html :: how to get a adminitration password for filezilla server 
ADD CONTENT
Topic
Content
Source link
Name
1+7 =