Tutorials and code for ASP.NET 2.0,C#,SQL Server,AJAX tutorials,jQuery  
Home    Articles    Contact Us
 

ASP.NET
AJAX
Interview Questions
Sql Server
Technology News
Tips and Tricks
jQuery

 

jQuery showing or hiding effects


In this article I explain some simple effects showing or hiding some elements on the page using jQuery.

In jQuery the two function show() and hide() simply work this.

Let's take example for show and hide div tag.
For that first takes two link for Show and Hide and div with some text.

<a href="#" id="btnShow">Show</a>
<a href="#" id="btnHide">Hide</a>
<div>Hello Demo for showing & hiding div using jQuery.</div>

In jQuery put script for showing or hiding elements insode $(document).ready() function.

   <script src="http://code.jquery.com/jquery-latest.js" ></script>

   <script>
    $(document).ready(function(){
   
      $('#btnShow').click(function(){
      $('div').show("fast"); });

      $('#btnHide').click(function(){
      $("div").hide(1000); });
    });
   </script>

In above code simply show/hide <div> tag when btnShow click it show <div> tag and when btnHide click it hide <div> tag.

In above code you can see dollar sign"$" is nothing but a shorthand notation for find method in JQuery.

How to use Selector?

If you want to select any element in the page then you can use dollar sign "$" to get that element.

  • Element Selector : for selecting all matching tag or elements use $('tagname') like  $('div').
  • ID Selector : for selecting element with the given id attribute use $('#id') like $('#btnShow').so,(#) used for access the element with id.
  • CSS selector: for find all element with a CSS class use $('.ClassName') select all element with ClassName CSS class..

In jQuery one more event toggle( ) which handle both events show() and hide().If they are shown, toggle makes them hidden (using the hide method). If they are hidden, toggle makes them shown (using the show method).

<a href="#" id="btnToggle">Toggle</a>

 $('#btnToggle').click(function () {
   $('div').toggle("slow"); });

In above all events show(speed),hide(speed),toggle(speed) use can specify speed for showing and hiding elements.Speed may be "slow","normal","fast" or the number of milliseconds to run the animation (e.g. 1000).

Related Article: Introduction of jQuery



User Comments:

Comment By Rzpzlhft on 11/05/2009

comment4
Comment By Diflvlmu on 11/05/2009

comment6
Comment By Fcwstjvt on 11/06/2009

comment2
Comment By Fcwstjvt on 11/06/2009

comment2
Comment By Euijpgcc on 11/06/2009

comment4
Comment By Rktyppdp on 11/06/2009

comment3
Comment By Qfwfiegk on 11/06/2009

comment3
Comment By Ptclqkhl on 11/06/2009

comment4
Comment By Ptclqkhl on 11/06/2009

comment4
Comment By Mgcpzqrm on 11/07/2009

comment3
Comment By Nwnsxfuo on 11/07/2009

comment3
Comment By Nnnshcqy on 11/07/2009

comment1
Comment By Nnnshcqy on 11/07/2009

comment1
Comment By Nnnshcqy on 11/07/2009

comment1
Comment By Tkxlouzd on 11/07/2009

comment5
Comment By Poawvxvr on 11/08/2009

comment6
Comment By Inwtkwbf on 11/08/2009

comment6
Comment By Jnhimaxu on 11/08/2009

comment3
Comment By Ltuapnit on 11/08/2009

comment3
Comment By Wfzhzcff on 11/09/2009

comment6
Comment By Qawaktnf on 11/09/2009

comment1
Comment By Gcacvkll on 11/09/2009

comment4
Comment By Zlaeloff on 11/09/2009

comment5
Comment By Gzvppmsb on 11/09/2009

comment3
Comment By Rpknkuxt on 11/10/2009

comment1
Comment By Slxronux on 11/10/2009

comment3
Comment By Hzhhzexb on 11/10/2009

comment5
Comment By Tynsfnuw on 11/10/2009

comment4
Comment By Zojkdbzd on 11/10/2009

comment2
Comment By Dyeupeau on 11/11/2009

comment6
Comment By Hhiyqfxl on 11/11/2009

comment6
Comment By Qfqvidfc on 11/11/2009

comment5
Comment By Ztifedty on 11/11/2009

comment5
Comment By Jzdtptkr on 11/11/2009

comment6
Comment By Apofgyox on 11/11/2009

comment3
Comment By Ilhfapid on 11/11/2009

comment1
Comment By Qjqhobed on 11/12/2009

comment4
Comment By Gnqnency on 11/12/2009

comment5
Comment By Lydmgfcw on 11/12/2009

comment3
Comment By Mfonovhb on 11/12/2009

comment1
Comment By Jhvffiqd on 11/12/2009

comment1
Comment By Zlthecwz on 11/12/2009

comment4
Comment By Vtvkfklf on 11/12/2009

comment6
Comment By Asaoizby on 11/12/2009

comment1
Comment By Dbyhcnfl on 11/12/2009

comment4
Comment By Gaiyvtwy on 11/12/2009

comment6
Comment By Jrlnzuof on 11/12/2009

comment3
Comment By Ruzjyiro on 11/13/2009

comment6
Comment By Bacdwtrj on 11/13/2009

comment5
Comment By Wnepjtmg on 11/13/2009

comment4
Comment By Nkgwgqqk on 11/13/2009

comment6
Comment By Ejbslcbq on 11/13/2009

comment1
Comment By Recvtbrc on 11/15/2009

comment5
Comment By Eenmfrny on 11/15/2009

comment3
Comment By Ilbgkdcw on 11/15/2009

comment6
Comment By Uupyhlyz on 11/15/2009

comment1
Comment By Xqwawuqh on 11/15/2009

comment1
Comment By Wifaphey on 11/15/2009

comment1
Comment By Gtftiyfy on 11/15/2009

comment1
Comment By Gtftiyfy on 11/15/2009

comment1
Comment By Wximxepb on 11/15/2009

comment2
Comment By Hkkdwyir on 11/16/2009

comment4
Comment By Dhkzbtfr on 11/16/2009

comment5
Comment By Skmbmpil on 11/16/2009

comment6
Comment By Bylntgfi on 11/16/2009

comment6
Comment By Etidippj on 11/16/2009

comment4
Comment By Ohyoipfc on 11/16/2009

comment3


Post Your Comment :


Name
Email:
Comment:

Home | Contact Us

© 2008-09 TechnoReader.com. All rights reserved.