I'm new to jQuery.. I'm using Visual Studio 2008.. In that I tried basic jQuery function.. But its not working.. My script coding is:
<title>
<script src="jquery-1.2.6.js" type="text/javascript" />
<script src="jquery-1.2.6-vsdoc.js" type="text/javascript" />
<script src="jquery-1.2.6.min.js" type="text/javascript" />
<script src=" http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript" />
<script type="text/javascript">
$(document).ready( function(){
$("#Button1").click(function(){
alert("Hello");
});
});
</script>
And my asp coding is:
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>
</body>
Can anyone tell my why its not working?
You are including jquery multiple times on the page - both minified and regular versions.
Reduce it to just one.
Use only one jquery js file.
remove this jquery file
<script src="jquery-1.2.6.min.js" type="text/javascript" />
<script src="jquery-1.2.6.js" type="text/javascript" />
and use only
<script src=" http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"
this will work.
and use button like this if you are just performing jquery operation
<input type="button" ID="Button1" Text="Button" />
When you are using the control from server side(asp controls).Use ClientID
to get that control
$(document).ready( function(){
$("#<%=Button1.ClientID%>").click(function(){
alert("Hello");
});
});
You can try after removing first three libraries:
<script src="jquery-1.2.6.js" type="text/javascript" />
<script src="jquery-1.2.6-vsdoc.js" type="text/javascript" />
<script src="jquery-1.2.6.min.js" type="text/javascript" />
and plz don't try doing inline closing of script:
<script src=" http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript">
</script>
modify your first block of code as below:
<title>My Test Page</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript" ></script>
<script type="text/javascript">
$(document).ready( function(){
$("#<%=Button1.ClientID%>").click(function(){
alert("Hello");
});
});
</script>
it will work.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.