开发者

Data table multiple row selection

开发者 https://www.devze.com 2022-12-25 13:40 出处:网络
How to change background color of row when I 开发者_JAVA百科click the checkbox?You need a shot of Javascript for this.

How to change background color of row when I 开发者_JAVA百科click the checkbox?


You need a shot of Javascript for this.

<h:selectBooleanCheckbox onclick="highlightRow(this)">

with

function highlightRow(checkbox) {
    getParentByTagName(checkbox, 'tr').style.background = (checkbox.checked) ? '#6f6' : 'none';
}
function getParentByTagName(element, tagName) {
    var p = element.parentNode;
    return p ? ((p.tagName.toLowerCase() == tagName.toLowerCase()) ? p : getParentByTagName(p, tagName)) : false;
}

Or if you're already using jQuery:

function highlightRow(checkbox) {
    $(checkbox).closest('tr').css('background', checkbox.checked ? '#6f6' : 'none');
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号