Pages

November 14, 2013

GrammarCatz Javascript: Show/Hide Images

I got such a nice comment from a real programmer at Google+ yesterday: he liked the little javascript I am using to do the show-hide images at my GrammarCatz blog posts. So, I thought I would share that here, in the spirit of "a little javascript goes a long way" - I know very little javascript, but I sure have been able to make good use of what I know. This is a little more complicated than my "Let the Fates decide" javascript, but not by much.

So, I've pasted in the HTML code for the GrammarCatz javascript here in a separate document, and I've reproduced yesterday's GrammarCat below so you can see how it works. For the actual commentary on the cat and an explanation of the English grammar, see the blog post: Grammar Cat #99: Monty Python Cat.

I'm sure there are much more elegant ways to do this, of course, but one of the great things about a teeny-tiny javascript like this that runs inside a blog post is that I just need for it to work. So, it shows the corrected cat and hides the corrected cat as the user requires, and that's all I need it to do! :-)

(Note that below I had to display the images at half the usual size so they would fit in the width of the post here; I have the post width set much wider at the GrammarCatz blog.)