简体   繁体   中英

CSS: How do I trigger a hover on each cell of a table if their table header is hovered?

假设我的表单元格中有不同种类的类来处理hover ,当它们的相应标头悬停在hover ,如何触发所有这些hover事件?

Here is a sample: http://jsfiddle.net/g0u2qtxo/2/

Snippet:

$(document).ready(function () {

$("#iTable td").hover(function () {
    alert("cell hover");
});

$("#iHead").hover(function () {
    alert("header hover");
    $("#iTable td").mouseenter();
});

});

Dependency: use jquery...

CSS effects to change style of rows on hover and JavaScript to handle click event.

See here: http://jsfiddle.net/5apnLjqt/

HTML:

<tr class="clickable" onclick="nav('http://www.google.com');">
        <td>Text</td>
        <td>Text</td>
</tr>

CSS:

tr.clickable:hover td { 
    background: #FFFF00; 
    cursor: pointer; 
}

JavaScript:

function nav (url) {
    window.open(url, '_blank');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM