Valid XHTML 1.0 Transitional

jQuery: reading an alt attribute with slice() function

flower1 flower2 flower3 flower4
The jQuery Code START
    
    <script type="text/javascript" 
    src="http://code.jquery.com/
    jquery-latest.js">
    </script>
    <script type="text/javascript">
      function getAlt() {
        alert($("img").slice(0,1).attr("alt"));
      }
      function getAlt2() {
        alert($("img").slice(1,2).attr("alt"));
      }
      function getAlt3() {
        alert($("img").slice(2,3).attr("alt"));
      }
      function getAlt4() {
        alert($("img").slice(3,4).attr("alt"));
      }
    </script>
    
    <style type="text/css">
      .code {color: red;}
      .back {background-color: yellow;}
    </style>
  </head>

  <body>
   <h1>jQuery: reading an alt attribute with slice() function</h1>
   
   <form action="">
   <input type="button" value="get top left Alt Attribute" onclick="getAlt()"></input>
    <input type="button" value="get top right Alt Attribute" onclick="getAlt2()"></input>
    <input type="button" value="get bottom left Alt Attribute" onclick="getAlt3()"></input>
    <input type="button" value="get bottom right Alt Attribute" onclick="getAlt4()"></input>
   </form>
   
   <img src="image1.jpg" alt="flower1"></img>
   <img src="image2.jpg" alt="flower2"></img>
   <img src="image3.jpg" alt="flower3"></img>
   <img src="image4.jpg" alt="flower4"></img>
   <br />