TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Learn JavaScript Part 7: getElementById() Method
Akshay Patel
Mar 20
2015
Code
1.1
k
0
2
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
getElementById
method is used to get the element with the specified id.
<!DOCTYPE html>
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head>
<title></title>
</head>
<body>
<div id=
"message"
>
Hello
</div>
<script id=
"javascript"
>
var
name = prompt(
"Enter Your Name"
,
""
);
document.getElementById(
'message'
).innerHTML += name;
</script>
</body>
</html>
User Input
Enter Your Name?
Akshay
Output
Hello Akshay
JavaScript
JavaScript getElementById Method