Javascript set focus on a table cell

How to set focus to table cell using javascript.In this article,I will explain how to set focus to table cell using javascript.We are using following JavaScript code to set focus on the Table row's cell.The focus() method is used to give focus to an element.

You can use javascript focus() method to set focus on element,set focus on input/textbox.In the following code we have created the function setFocus() in the JavaScript to show the use of "focus()" method. This function would be called when any user clicks on the link "Set Focus to Table Cell".
The javascript code below shows how to set the focus on an element/input field (textbox).

Example: How to set focus on a table column.
<script Language="javascript">
function setFocus(){
  <span><a href='javascript:void(0);' onClick="javascript:setFocus();">Set 
Focus to Table Cell</a></span><br><br><br>
<table  cellspacing="0" cellpadding="0" border='1'  id="table_l" 
<td><input type="text" name="textbox2" id="textbox2"></td>
<td><input type="text" name="textbox3" id="textbox3"></td>

You can use this logic to set focus to element,input/textbox,div element as well.