Advertisement
Guest User

.click event called twice???

a guest
Jan 18th, 2012
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 0.75 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html>
  4.     <head>
  5.         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6.         <title>Oh noooo!</title>
  7.         <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
  8.         <script type="text/javascript">
  9.         $(document).ready(function () {
  10.             $("#myDiv").append($("<input />", {
  11.                                 type : "button",
  12.                                 id : "myButton1",
  13.                                 value : "Click me first!"
  14.                             }));
  15.             $("#myButton1").live("click", function () {
  16.                 var a = 1;
  17.                 $("#myButton2").click(function () {
  18.                     alert(a);
  19.                 });
  20.             });
  21.         });
  22.         </script>
  23.     </head>
  24.     <body>
  25.         <div id="myDiv"></div>
  26.         <input type="button" id="myButton2" value="Click me!" />
  27.     </body>
  28. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement