JavaScript, HMLT: changing color of selected row in table
2021. 8. 14. 23:28ㆍFrontend/Web programming
- 목차
반응형
<table id="time_table"
...
<tr onclick="javascript:onRowSelected(this);">
<td> ... </td>
<script type="text/javascript">
function onRowSelected(target) {
var tbody = target.parentNode;
var trs = tbody.getElementsByTagName('tr');
var bg_color = "#ffffff";
var text_color = "black";
var sel_bg_color = "#82B27D";
var sel_text_color = "#ffffff";
var upm_id = "";
var upm_name = "";
for (var i = 0; i < trs.length; i++) {
if (trs[i] != target) {
trs[i].style.backgroundColor = bg_color;
trs[i].style.color = text_color;
} else {
trs[i].style.backgroundColor = sel_bg_color;
trs[i].style.color = sel_text_color;
var td = trs[i].getElementsByTagName('td');
upm_id = td[0].innerText;
upm_name = td[1].innerText;
}
}
...
반응형
'Frontend > Web programming' 카테고리의 다른 글
TypeScript (0) | 2021.12.05 |
---|---|
Update values of the Flask forms in JavaScript section (0) | 2021.09.02 |
Flask: update form value at JavaScript code (0) | 2021.08.14 |
JavaScript: AJAX call w/ Flask (0) | 2021.08.14 |
JavaScript "Failed to find a valid digest in the 'integrity' attribute ..." (0) | 2021.08.13 |