Javascript set focus on a table cell
Posted by Raj
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.
<html>
<head>
<script Language="javascript">
function setFocus(){
document.getElementById("textbox2").focus();
}
</script>
<Body>
<span><a href='javascript:void(0);' onClick="javascript:setFocus();">Set
Focus to Table Cell</a></span><br><br><br>
<strong>Table</strong>
<table cellspacing="0" cellpadding="0" border='1' id="table_l"
id="table_l">
<tr>
<td><strong>Cell1 </strong></td>
<td><input type="text" name="textbox2" id="textbox2"></td>
</tr>
<tr>
<td><strong>Cell2 </strong></td>
<td><input type="text" name="textbox3" id="textbox3"></td>
</tr>
</table>
</Body>
</head>
</html>
You can use this logic to set focus to element,input/textbox,div element as well.
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.
<html>
<head>
<script Language="javascript">
function setFocus(){
document.getElementById("textbox2").focus();
}
</script>
<Body>
<span><a href='javascript:void(0);' onClick="javascript:setFocus();">Set
Focus to Table Cell</a></span><br><br><br>
<strong>Table</strong>
<table cellspacing="0" cellpadding="0" border='1' id="table_l"
id="table_l">
<tr>
<td><strong>Cell1 </strong></td>
<td><input type="text" name="textbox2" id="textbox2"></td>
</tr>
<tr>
<td><strong>Cell2 </strong></td>
<td><input type="text" name="textbox3" id="textbox3"></td>
</tr>
</table>
</Body>
</head>
</html>
You can use this logic to set focus to element,input/textbox,div element as well.
This entry was posted on October 4, 2009 at 12:14 pm, and is filed under
focus javascript,
javascript focus,
javascript focus textbox,
javascript set focus input,
javascript set focus on element,
javascript set focus on input,
setfocus in javascript,
setting focus in javascript
.You can leave a response, or trackback from your own site.