0
need urgent help!!! homework assignment, only javascript.
New to javascript and looking for help for my homework... Any help appreciated . Using pure JavaScript, to highlight a complete table data row when row[0] is selected. Clicking again deselects the row. (note -- should not be able to select and highlight the title row!) A button that saves the contents of the current table (to a cookie) and a button that loads saved contents into the table (from a cookie). thanks in advance
4 Réponses
+ 1
Hello amy,
Are you looking for something like that?
http://codepen.io/anon/pen/ryLOdg?editors=1111
A tips:
If you want to highlight every lines except the table's head you can choose to target <td> only or you can play with the for( var i = 0 and change the value of "i" to start with another row.
+ 1
There we go :
theTableRows[i].onclick = function(){
if(this.style.backgroundColor == "red"){
this.style.backgroundColor = "transparent";
}else{
this.style.backgroundColor = "red";
}
};
0
@Geoffrey
Thanks for your help Geoffrey. More or less similar but I should be using onclick instead of mouseover. When you click on row[one] cell [one] it should highlight the whole row and clicking again unhighlights (deselects) the row.
0
@Geoffrey
Thanks so much. Its working. now i have to work on looping it so that i can do it for every row and in the same way i can able to do for columns too.
http://codepen.io/anon/pen/LWZxEK