jQuery selector triggering two suplicate events???
Posted: Sun Oct 25, 2009 11:31 pm
I have the following code:
When I click the cancel button, I am prompted twice to actually cancel or continue, WTF?
Anyone know whats going on here?
Cheers,
Alex
Code: Select all
<!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" xml:lang="en" lang="en"> <head> <base href="http://www.somedomain.com/" /> <title>This is the document title</title> <script type="text/javascript" src="jquery.js"></script> </head> <body> <script type="text/javascript"> //<![CDATA[ if(typeof jQuery != 'undefined'){ $(document).ready(function() { $("#frm_0a7df113baa1138c0c06e9d087cd9e56_0, .btn_cancel").click(function() { var ret = confirm("Are you sure you want to cancel and return to the previous screen?"); if(ret){ location.href("/"); } }); }); } //]]></script> <form id="frm_0a7df113baa1138c0c06e9d087cd9e56_0" action="/auth/login2" method="post" enctype="text/html"> <div> <!-- Enter INPUT fields here --> </div> <div> <button type="submit">OK</button> <script type="text/javascript"> document.write('<button class="btn_cancel">Cancel</button>'); </script> <noscript> <div class="note"> <a href="/">Click here to return to the previous screen</a> </div> </noscript> </div></form </body></html>Anyone know whats going on here?
Cheers,
Alex