HTML DOM Input Email size Property
The Input Email size property in HTML DOM is used to set or return the value of the size attribute of an Input Email Field. The size attribute is used to define the width of an email field. Its default value is 20.
Syntax:
Property Value: It contains single value number which is used to specify the width of an email field in terms of the number of characters.
Return Value: It returns the numeric value which represents the width of an email field in terms of number of characters.
Example 1: This example illustrates how to return Input Email size property.
html
<!DOCTYPE html>
< html >
< head >
< title >
HTML DOM Input Email size Property
</ title >
</ head >
< body style = "text-align:center;" >
< h1 >GeeksforGeeks</ h1 >
< h2 >HTML DOM Input Email size Property</ h2 >
< label >E-mail:</ label >
< input type = "email" id = "email"
name = "myGeeks" size = "10" >
< br >< br >
< button onclick = "myGeeks()" >
Click Here!
</ button >
< p id = "result" ></ p >
< script >
function myGeeks() {
let email = document.getElementById("email").size;
document.getElementById("result").innerHTML = email;
}
</ script >
</ body >
</ html >
|
Output:
Example 2: This example illustrates how to set Input Email size Property.
html
<!DOCTYPE html>
< html >
< head >
< title >
HTML DOM Input Email size Property
</ title >
</ head >
< body style = "text-align:center;" >
< h1 >GeeksforGeeks</ h1 >
< h2 >
HTML DOM Input Email size Property
</ h2 >
< label >E-mail:</ label >
< input type = "email" id = "email"
name = "myGeeks" size = "10" >
< br >< br >
< button onclick = "myGeeks()" >
Click Here!
</ button >
< p id = "result" ></ p >
< script >
function myGeeks() {
let email_size = document.getElementById(
"email").size= "30";
document.getElementById("result").innerHTML
= "Value of size attribute changed to "
+ email_size;
}
</ script >
</ body >
</ html >
|
Output:
Supported Browsers:
- Google Chrome 5
- Edge 12
- Firefox 1
- Opera 11
- Safari 5
Last Updated :
29 Jan, 2024
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...