Ich versuche, fokussierte <tr>
s zu markieren.CSS: Fokus-Selektor funktioniert nicht, wenn Element mit .focus() fokussiert ist
Ich habe ein tabindex von -1
zu jedem von ihnen gegeben, und bestätigte, dass Aufruf some_tr.focus()
Sätze document.activeElement
zu diesen some_tr
. Aus irgendeinem Grund wird jedoch some_tr
nicht durch die CSS-Regel tr:focus
hervorgehoben.
Es sollte darauf hingewiesen werden, dass für mich (Firefox 54), klicken Sie auf <tr>
manuell tut verursachen, dass es hervorgehoben werden.
document.getElementById("that_tr").focus();
console.log(document.activeElement);
tr:focus {
background:lightblue;
}
<table>
<tr>
<th>part</th>
<th>peice</th>
<th>thing</th>
<th>stuff</th>
</tr>
<tr tabindex="-1">
<td><span>data1</span></td>
<td><span>data1</span></td>
<td><span>data1</span></td>
<td><span>data1</span></td>
</tr>
<tr id="that_tr" tabindex="-1">
<td><span>data2</span></td>
<td><span>data2</span></td>
<td><span>data2</span></td>
<td><span>data2</span></td>
</tr>
</table>
Warum that_tr
nicht in der obigen Schnipsel werden hervorgehoben? Wie kann ich das zur Arbeit bringen?
Ich sehe die Hervorhebung, wenn ich Ihr Snippet ausführe. – Barmar
Es funktioniert in Chrome, Safari und Firefox. – Barmar
Ich kann bestätigen, dass es nicht funktioniert in Firefox 54.0a2 – IiroP