Web Design IES
Web Design in Easy Steps, now in its 7th Edition, shows you how to make effective websites that work on any device.
One of the most useful things you can do with javascript and CSS is to make things appear and disappear when you want to. It means you can focus the user's attention on what's needed at a particular stage of a process (eg e-commerce), or you can create special effects by making text or graphics pop onto the screen instantly.
I created a tool that enables people to get their copy of my novel Earworm signed over the internet. This uses the script to good effect to make the 'signed' letter instantly appear.
There are lots of javascript and CSS libraries that have features built in to hide and reveal different sections of the page, but they usually carry a heavy download penalty. Unless you wanted to use the library for something else (and something much more difficult, at that), then you're better off adapting this short free script to hide and reveal webpage content.
I've got hiccups. Give me a surprise!
This is easy. Here are three steps to getting it working:
<div id="hideaway" style="display:none;">Here's the hidden content</div>
<a href="javascript:;" onClick="document.getElementById('hideaway').style.display='block';">Reveal hidden content</a>
<a href="javascript:;" onClick="document.getElementById('hideaway').style.display='none';">Hide content again</a>
The content that you make appear and disappear can include image tags and any other HTML - it's just text in the above to make it easier to understand.
That technique is fairly basic, but it underlines some quite sophisticated effects. Here are some ideas for other ways to use it:
<input type="button" value="Open application form" onClick="document.getElementById('hideaway').style.display='block';">
<a href="javascript:;" onClick="document.getElementById('hideaway').innerHTML='new html goes here';">Update the HTML</a>
© Sean McManus. All rights reserved.
Visit www.sean.co.uk for free chapters from Sean's coding books (including Mission Python, Scratch Programming in Easy Steps and Coder Academy) and more!
Web Design in Easy Steps, now in its 7th Edition, shows you how to make effective websites that work on any device.
Power up your Microsoft Excel skills with this powerful pocket-sized book of tips that will save you time and help you learn more from your spreadsheets.
This book, now fully updated for Scratch 3, will take you from the basics of the Scratch language into the depths of its more advanced features. A great way to start programming.
Code a space adventure game in this Python programming book published by No Starch Press.
Discover how to make 3D games, create mazes, build a drum machine, make a game with cartoon animals and more!
In this entertaining techno-thriller for adults, Sean McManus takes a slice through the music industry: from the boardroom to the stage; from the studio to the record fair.