JavaScript Tutorial will teach us about the JavaScript use with buttons. We can
create effects using images as buttons. Here we need some images for use with
JavaScript and three images for the different stages like normal, active and
clicked. When the user moves his mouse over the first image, then the image will
be switch to the active second image. When the user clicks the active image, the
image will be switch to
third clicked image, this process is just for showing the 3D effect. Like as under
This is an effect that will create the feelings like a 3D button. JavaScript buttons are also
known as mouse over buttons. JavaScript buttons can give nice effects to our
web page. If its work is done properly, then JavaScript buttons give very impressive look and feel
to the viewer.
In this section of JavaScript Tutorial we will show you the creation of simple effects using JavaScript
and how to attach JavaScript with the traditional
HTML form buttons. Like
as under.
On the above JavaScript with button example as shown we write down our own
JavaScript function with the name of
showOutput(message) in
HEAD section of an
HTML file, it is better to use always
follow the same convention mean write your all the JavaScript in
HEAD instead of
BODY. And you will see that on almost all web site the JavaScript will be
available in
HEAD Tag. The reason for this method is that the
HEAD Tag always load or execute before BODY of an
HTML document that's why if we
use some JavaScript function and suppose we write if in BODY and use may or may
not it will be execute. Because suppose we use it before written in the
document. It is better to always use JavaScript in
HEAD Tag of HTML
document.