Click here to Skip to main content
16,007,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Masterpage

<script src="Scripts/jquery-1.4.1-vsdoc.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript">

</script>


contentpage


<script type="text/javascript">
document.ready(function () {

$('#' + '<%=btnSubmit.ClientID %>').click(function () {
$("p").hide();
});
});
</script>


Welcome to ASP.NET!



To learn more about ASP.NET visit www.asp.net.



You can also find
title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN
.


<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
Posted
Updated 24-Sep-13 18:16pm
v2

1 solution

There are 2 mistakes in your code which will not make it work:

JavaScript
document.ready(function () { //This is wrong sytax

it should be
JavaScript
$(document).ready(function () {


The other thing is that the button is a submit server side button, so even after the p tags are hidden, after the load of the page, everything will be loaded again. Hence for this to work, you will have to prevent the server side eventing.

Check the corrected code below:

XML
<script type="text/javascript">
$(document).ready(function () {

$('#' + '<%=btnSubmit.ClientID %>').click(function () {
$("p").hide();
return false;//This important to avoid reload of the page again, which will again make the <p> tags visible.
});
});
</script></p>
 
Share this answer
 
v3
Comments
Member 10295662 25-Sep-13 2:49am    
thanks alot

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900