Before we start writing our MooTools plugin, we'll take an additional step; we're going to write a functional script that accomplishes the task we've set out to do, which is to automatically caption images in a web page using their alt
(or title)
property. Imagine auto-captioning 20 images (or more) in a web page without having to do much other work than assigning them an alt
or title
property? This reduces the amount of HTML we have to write, which in turn, reduces HTML clutter and file size.
Start with some HTML by putting images in a web page. In this web page, place three image elements (encapsulating these image elements inside a
p
tag is optional). For the first image, include analt
property/value pair. For the second image, do not provide anyalt
ortitle
property/value pairs. This will serve as a test case on how our script will work without an image caption. The third one will have a title property instead of an alt property.<h1...