set the focus on an element using Javascript

Ads
 

set the focus on an element using Javascript

How to set the focus on an element using Javascript?

View Answers

November 9, 2010 at 4:19 PM

We can set the focus on the elements in the html page using java script as follows-

This the sample code for doing this-

<head>
<script type="text/javascript">
function setFocus()
{
     document.getElementById("Name").focus();
}
</script>
</head>

<body onload="setFocus()">
  <form>
       Full Name:<input type="text" id="Name" size="20"><br />
       Password: <input type="Password" id="Password" size="20">
  </form>
</body>

Ads









Related Tutorials/Questions & Answers:
JavaScript Focus method
JavaScript Focus method JavaScript focus() method is used to set focus.... JavaScript focus is used to set the focus or get the focus. It can be apply.... Generally when we do coding then we want to set the focus to a particular
JavaScript focus method
JavaScript focus method       JavaScript focus method can be used to set focus..._Object.focus(); Where element_Object is the element to whom we have to set focus
Advertisements
focus() In JavaScript
focus() In JavaScript In this section we will read about how to specify the focusing location on a window. focus() method in JavaScript is used to specify... that a user can easily understand using which element the information has
javascript focus input
input field in the page. It can be performed using focus() method on the html element. To understand how focus can be set to any input field, we have created... javascript focus input
how to access element added via javascript dynamically using jsp code
how to access element added via javascript dynamically using jsp code ... javascript dynamically using the jsp code. i am adding empty records on .jsp page using javascript (by calling a below function on click event of button
JavaScript Remove Focus
; In this section, you will learn how to remove focus from the window using JavaScript... JavaScript Remove Focus... you load the 'removeFocus.html' code, you will get a button 'Set Focus
remove parent element JavaScript
remove parent element JavaScript  How to remove parent element in JavaScript
JavaScript Remove Element
; In this section, you will learn how to remove HTML element using JavaScript. JavaScript provides several methods which allow the user to remove particular HTML element... JavaScript Remove Element
javascript hide element
javascript hide element  How can we hide / show HTML elements using JavaScript
property in javascript get set
property in javascript get set  How to create the get and set property in JavaScript?   Creating Get and Set properties in JavaScript example.. myVar Sample = { nval : "", get get() { return this.nval; }, set
javascript set scroll height
javascript set scroll height  How to set scroll height in JavaScript?   CSS Scroll Method div { width:150px; height:150px; overflow:scroll; } JavaScript ScrollTo method <script type="text/javascript">
how can i set an object in focus
how can i set an object in focus  There is a Canvas object in my game and this object is not set in focus, because of this my snake is not moving... is not moving, so someone suggest me that your canvas object is not in focus
Wiring References To Set Element
to demonstrate how set element is used. Product.java: The product class contains property...Wiring references to <set> element The <set> element is used to store multiple unique values. Its sub element <ref> element can be used
JavaScript Array Remove Element
JavaScript Array Remove Element In this example we will describe JavaScript... JavaScript array's Splice() method. Splice method remove an element...; <head> <title> JavaScript array remove element example <
using for loop in javascript
using for loop in javascript  How to use for loop in JavaScript
xls to js using javascript
xls to js using javascript  ![how can we convert a xls file in js file using javascript][1
timer using javascript
timer using javascript  How to display timer on HTML page using JavaScript
Changing background color using JavaScript
Changing background color using JavaScript  Hi Sir Is there any way to change the background color using JavaScript ? Please mention code with your answer.   Hello Friend Pass the element & color in the given
JavaScript array replace element
JavaScript array replace element       In the JavaScript array there is not any...() method by using the in-built splice() method. We have already discussed the splice
send mail using JavaScript
send mail using JavaScript  How can we send mail using JavaScript?   Hi friends, You can not send email directly using JavaScript. But you can use JavaScript to execute a client side email program send the email using
validate radio button using javascript
validate radio button using javascript  validate radio button using javascript
JavaScript Add Element to Array
JavaScript Add Element to Array       In the given JavaScript example, we have created an array... through the example you will learn about how to add element to an array using
write a program to remove the element from hashset using keyboard.
write a program to remove the element from hashset using keyboard.  write a program to remove the element from hashset using keyboard
JavaScript array first element
JavaScript array first element  ... a code that makes you easy to understand in array first element example. For this we are using Java Scripting language This code show a page on loading
JavaScript array remove an element
JavaScript array remove an element   ... remove element example </title> <script type="text/javascript">...="#ddcdff"> <h2> JavaScript array remove element </h2> <
Using redirect element & wild card
Using redirect element & wild card  ...; is an optional element which can be used to specify that the response is generated by the new view using redirect response rather than rendering the response
how to give validation using javascript in swing
how to give validation using javascript in swing   how to give validation using javascript in swing....... can somebody give code for username and password validation using javscript and swing
javascript date validation using regex
javascript date validation using regex  Hi, I want to validate the date using javascript. Please help.   <html> <head> <title>Validating Date format</title> <script type="text/javascript">
remove duplicates from list in java using set
this? Tell me program for the removal of duplicates from list in java using set... duplicates from list in java using set: import java.util.Arrays; import java.util.List...remove duplicates from list in java using set  Hi, I have a list
How to write a search functionality using javascript/jquery
How to write a search functionality using javascript/jquery   How to write a search functionality using javascript/jquery for ex: im searching "s" names it wil display "s" names
JavaScript - JavaScript Tutorial
JavaScript focus method can be used to set focus to the current window... with the Java Scripting language. You will learn the benefits of using JavaScript... will learn how to create popup window using JavaScript.   Form

Ads