Monday, October 10, 2011

How to set focus on Table row using Javascript

Leave a Comment
We are developing Application for Google Smart TV and all is going well.

We are using Table, Div or some other elements which cannot be focused on using .focus() of java script.

We have used Table to show data in one of our page. Our target is to set the focus on first element of table i.e. first row.

We tried different solutions suggested on web but nothing worked. All the posts are suggesting to use focusable controls like text box, check box etc.

Finally we found solution on http://groups.google.com/group/mozilla.dev.tech.css/browse_thread/thread/42591922d95c6399

In the post "Stanimir Stamenkov" has used a term "if you just define a 'tabindex' on the element it becomes focusable" I assigned "tabindex" property to table row and then used .focus() and the focus reached to row.


Hope this will help all who are looking for such nice solutions.

0 comments: