set the focus on an element using Javascript

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>









Related Tutorials/Questions & Answers:
set the focus on an element using Javascript
set the focus on an element using Javascript  How to set the focus on an element using Javascript
checkboxes set to true using JavaScript
checkboxes set to true using JavaScript  To set all checkboxes to true using JavaScript
Advertisements
JavaScript Focus method
JavaScript Focus method JavaScript focus() method is used to set focus... in all browser. JavaScript focus is used to set the focus or get the focus. It can.... 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... are providing you a simple example to set the focus to the input text box. Not only
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
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
Add and Delete Element Using Javascript in JSP
Add and Delete Element Using Javascript in JSP... developed an application to add and delete element using javascript . We created two... person"); document.getElementById(person).focus(); return false
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
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
Pick random element from Set
Pick random element from Set A Set is a collection that contains no duplicate... the mathematical set abstraction. Here, we are going to pick an element randomly from... to the collection. An object of Random class is created to retrieve any element from the Set
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
Test hidden element using JQuery
Test hidden element using JQuery  Suppose i have an element which i am hiding and showing, using .hide(), .show() or .toggle().How do you test to see... using following code snippet :ADS_TO_REPLACE_1 $(element).is(":visible") Hope
JDOM Element Example, How to set attribute of xml element in java.
JDOM Element Example, How to set attribute of xml element in java. In this tutorial, we will see how to set attribute of xml element in java with the help...(String name, String value)method set a attribute of an element with given name
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...; <body> <h2> JavaScript array remove element </h2> <
focus
focus  focus is on a textbox. when a barcode reader read barcode and send to the same textbox which method i used in jsp to retrive data from database
delete an entry using JavaScript
delete an entry using JavaScript  How to delete an entry using JavaScript
Date object using JavaScript
Date object using JavaScript  What's the Date object using JavaScript
using for loop in javascript
using for loop in javascript  How to use for loop in JavaScript
Position one element relative to other using JQuery.
Position one element relative to other using JQuery.  Hello Sir...; then you can use the following JavaScript code : $("#placeholder").mouseover... of the placeholder element var pos = $("#placeholder").offset(); var width
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
maximize an image using javaScript
maximize an image using javaScript  Write the code to maximize an image using 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
Getting the ID of the element that fired an event using JQuery
Getting the ID of the element that fired an event using JQuery  Hello sir I want to know-Is there any way to get the ID of the element that fires... friend In jQuery event.target always refers to the element that triggered
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
How to shift and unshift using JavaScript?
How to shift and unshift using JavaScript?  How to shift and unshift 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
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
convert numbers to strings using JavaScript
convert numbers to strings using JavaScript  How to convert numbers to strings using JavaScript
Math Constants and Functions using JavaScript
Math Constants and Functions using JavaScript  What's Math Constants and Functions using JavaScript
validate radio button using javascript
validate radio button using javascript  validate radio button using javascript
read and write a file using javascript
read and write a file using javascript  How to read and write a file using javascript
associate functions with objects using JavaScript
associate functions with objects using JavaScript  How to associate functions with objects using JavaScript
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 remove an element
JavaScript array remove an element   ...; JavaScript array remove element example </title> <script type="text...;body bgcolor="#ddcdff"> <h2> JavaScript array remove element <
Sorting Vector Element using I18N
Sorting Vector Element using I18N       This Example shows you how to sort vector element using I18N. In the code given below we are sorting some elements using some rules
how to set values from parent page to iframe in javascript
how to set values from parent page to iframe in javascript  how to set values from parent page to iframe in javascript pls reply me as possible as I am in great trouble
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
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
Solve using only Javascript loops...
Solve using only Javascript loops...  Write a JavaScript code, 1) to find a number of unique letters in string. (Eg. if keyword is unique, Unique count will be '4') 2) so that numbers appear in following format, 1 1 2
Bind custom event with an element using 'bind'
Bind custom event with an element using 'bind' In this tutorial, we will discuss about how to bind a user define event with an element using 'bind ' function of jQuery. In this example ,  we are firing an user
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

Ads