1. Alexander Dahl
  2. head-first-jquery

Commits

Alexander Dahl  committed d000642 Draft

create new page based on last one and put js to a separate file

  • Participants
  • Parent commits 4be38e5
  • Branches default

Comments (0)

Files changed (2)

File page87.html

View file
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" lang="de" xml:lang="de">
+<head>
+    <title>Jump for Joy</title>
+    <link rel="stylesheet" type="text/css" href="styles/page39.css" />
+</head>
+<body>
+    <div id="header">
+        <h1>Jump for Joy Sale</h1>
+    </div>
+    <div id="main">
+        <div class="guess_box"><img src="images/jump1.jpg" alt="jump 1" /></div>
+        <div class="guess_box"><img src="images/jump2.jpg" alt="jump 2" /></div>
+        <div class="guess_box"><img src="images/jump3.jpg" alt="jump 3" /></div>
+        <div class="guess_box"><img src="images/jump4.jpg" alt="jump 4" /></div>
+    </div>
+    <script src="scripts/jquery-1.6.4.min.js" type="text/javascript"></script>
+    <script type="text/javascript" src="scripts/page87.js"></script>
+</body>
+</html>

File scripts/page87.js

View file
+function checkForCode() {
+    var discount = Math.floor((Math.random()*5) + 5);
+    var disc_msg = "<p>Your Discount is " + discount + "%<\/p>";
+    // alert(discount);
+    $(this).append(disc_msg);
+
+    // $(this).unbind("click");
+    $(".guess_box").unbind("click");
+    // $(".guess_box").each(function(){
+    //     $(this).unbind("click");
+    // });
+}
+
+$(document).ready(function(){
+    $(".guess_box").click( checkForCode );
+}); // \ready