With jQuery, in (document).ready I assigned a click function to all buttons of my asp.net (aspx) page. When I click a button outside , the function works properly. When clicking a button INSIDE the form, it doesn't work. Why?
Here my default.aspx page:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="jQuery._Default" %>
<!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">
<head runat="server">
<title></title>
<script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("button").click(function () {
$("input").before("ciao");
});
});
</script>
</head>
<body>
<button id="Button1">Button BEFORE Form</button>
<button id="Button2">Another BEFORE Form</button>
<form id="form1" runat="server">
<button id="btStart">Button in Form</button>
<div>
<input type="text" value="I like number 1" />
<input type="text" value="Smile to number 2" />
</div>
</form>
</body>
</html>
I'm using Visual Studio 2010. I tried also with jQuery 1.4.2, same problem.
Thanks for letting me know, cheers.