highlightRows function


/ Published in: JavaScript
Save to your folder(s)

A JS function that makes bold the text of table rows ("tr" elements) when you "mouseover" them. It takes no arguments.

From book Dom Scripting by Jeremy Keith.


Copy this code and paste it in your HTML
  1. function highlightRows() {
  2. if(!document.getElementsByTagName) return false;
  3. var rows = document.getElementsByTagName("tr");
  4. for (var i=0; i<rows.length; i++) {
  5. rows[i].onmouseover = function() {
  6. this.style.fontWeight = "bold";
  7. }
  8. rows[i].onmouseout = function() {
  9. this.style.fontWeight = "normal";
  10. }
  11. }
  12. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.