Actually your script is not binding the click event to the button. Because it has the attribute runat=server
. So it will change the id of the elements at the time of rendering. you should either use a class name or clientID
instead of id.
using class name,
<script type="text/javascript">
$(document).ready(function () {
$(".txt1").focusout(function (e) {
e.stopPropagation();
$(".lbl1").text("aaaa");
});
$('.btn1').click(function (e) {
e.stopPropagation();
alert("clicked");
});
});
</script>
<asp:Label ID="lbl1" CssClass="lbl1" runat="server" />
<asp:TextBox ID="txt1" CssClass="txt1" runat="server" />
<asp:Button ID="btn1" CssClass="btn1" runat="server" />
Edit
The problem is with the position of label. Please check this Fiddle