JavaScript Message On Button Click:
I just start with Java Script and i want to print a simple message in html page on button click by simple javascript.
Change HTML Content And Print Custom Content:
First i create a simple Html Page by the html tags.in this we take one <p> tag and one button tag in <body> section. As like that.
<!DOCTYPE html PUBLIC "-//W3C//DTD
XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<body>
<h1>Print A simple Java script Message </h1>
<p id="mes">JavaScript message show here after button click.</p>
<button type="button"
onclick="document.getElementById('mes').innerHTML
= 'Hello JavaScript!'">
Click Here!</button>
</body>
</html>
<button type="button"
onclick="document.getElementById('mes').innerHTML = 'Hello JavaScript!'">
Click here</button>
Take a Html button and print a simple text message.
Define the id of tag <p> and try to call this on button onclick event.
write this code in html page and open the html page on browser see the result.
No comments:
Post a Comment