A Little Javascript

This is a tutorial that takes you through adding a little bit of javascript to a page.  The javascript takes a part of the page that is invisible and makes it visible.   The finished files are here:

ShowOnClickDemo

You can download them and give it a try.  Before you even start, you need a thing on your page that is hidden.  To do this, make a “div” that looks like this:

index_html

Then add a style to your style sheet that hides it.  The style looks like this:

style_css

To use javascript on your page, you should do two things.  Write a link that instead of going to another file, calls a javascript function.  That looks like this:

index_html

The javascript function is called talk( ).  We’ll write that next.

In the <head> of your page, add a <script type = “text/javascript”> tag, and a </script> tag.

In between those go any javascript functions you write.  The talk( ) function looks like this:

 

index_html

Then load your page.  The element starts hidden, but when you click “talk to the bear”, it becomes visible.