Click here to Skip to main content
15,917,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
hello,
i am new for jquery, i have written this simple jquery function but its not working, i have downloaded the latest jquery version and saved in root directory under jquery folder..


<script type="text/javascript" src="jquery/jQueryv1.9.1.js"></script>

<script type="text/javascript">

$(document).ready(function(){

('#toview').click(function(){

('#sub').hide();

});

});

</script>


<a id="toview" href="#">click to hide</a>

    <br />

    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>

    <div id="sub"><asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click"/></div>


help please
Posted
Comments
ZurdoDev 25-Mar-13 8:05am    
What is happening? Put a breakpoint and see what happens.
Ankur\m/ 25-Mar-13 8:13am    
[moved from answer]
OP wrote:
actualy sir nothing is happening,i thought there is some problem in installation of jquery here is my way to installation... i clicked the installation link in offical jquery site it redirected me to simple text file in browser, i have selected all and copied it in one .js file in visual studio root file, is this way correct to install jquery?
ZurdoDev 25-Mar-13 8:17am    
Yes, you can "install" it that way. Did you put a breakpoint on $(document).ready()? If so, when the page loads it should hit your breakpoint.
Ankur\m/ 25-Mar-13 8:23am    
You should have better added a direct comment. Anyways, I have answered the question. He is missing the almighty '$' before the selectors. :)
ankitsrist 25-Mar-13 8:28am    
thanks to both of you

1 solution

You are missing the $ sign (or jQuery) before ('#toview') and ('#sub'). Just add it and it will be fine.
So your code will be:
JavaScript
$(document).ready(function(){
    $('#toview').click(function(){
        $('#sub').hide();
    }); 
});
 
Share this answer
 

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