Result jQueryjQuery(function($) { //data-hrefの属性を持つtrを選択しclassにclickableを付加 $('tr[data-href]').addClass('clickable') //クリックイベント .click(function(e) { //e.targetはクリックした要素自体、それがa要素以外であれば if(!$(e.target).is('a')){ //その要素の先祖要素で一番近いtrの //data-href属性の値に書かれているURLに遷移する window.location = $(e.target).closest('tr').data('href');} }); });csstd, th { padding: 5px 10px; } thead th { background: #110303; color: #
![テーブルの行ごとリンクをクリック出来るようにする](https://cdn-ak-scissors.b.st-hatena.com/image/square/b6b1c87ada2ad66409793e3653c810e333009609/height=288;version=1;width=512/http%3A%2F%2Fkachibito.net%2Fwp-content%2Fuploads%2F2019%2F12%2Fsite-icon.png)