如何聚焦< tr>或< td>使用jQuery或JavaScript标记? [英] How to focus a <tr> or <td> tag using jQuery or JavaScript?
本文介绍了如何聚焦< tr>或< td>使用jQuery或JavaScript标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
for(var i=0;i<tr.length;i++){
var td = tr[i].getElementsByTagName("td");
if(td[2].innerHTML==time && td[3].innerHTML==cls){
td[0].setAttribute("id","focus");
tr[i].style.backgroundColor="green";
var foc = document.getElementById("focus");
foc.focus();
cnt++;
}
else{
tr[i].style.backgroundColor="transparent";
}
}
推荐答案
这已经为时已晚,但是您 CAN 专注于TD元素.只需为其提供一个tabindex属性,然后执行focus().
This is a year too late, but you CAN focus to a TD element. Just give it a tabindex property, and then do a focus().
这适用于DIV元素和几乎所有其他元素.
This works for DIV elements and almost all others.
我已经在Firefox 3.5及更高版本上尝试过此操作.
I've tried this on Firefox 3.5 and up.
这篇关于如何聚焦< tr>或< td>使用jQuery或JavaScript标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文