you don't have to do that check. If the element does not exist, the
show() code will not be run.



On Thu, Mar 26, 2009 at 4:40 AM, shobhitsoftskills
<shobhitsing...@gmail.com> wrote:
>
> hi,
>
> i am learning jQuery and confused about one thing.below is simple code
> using jQuery.
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
>  "http://www.w3.org/TR/html4/strict.dtd";>
> <html>
>
> <head>
>
> <script type="text/javascript" src="jquery.js"></script>
>
> <script type="text/javascript">
> $(document).ready(function() {
> if ( $('#myDiv').length )
>  $('#myDiv').show();
>
> });
> </script>
>
> </head>
>
> <body>
>  <div id="myDiv">Search Engines</div>
> </body>
>
> </html>
>
>
>
>
>
> i am trying below lines.
>
> if ( $('#myDiv').length )
>  $('#myDiv').show();
>
> according to this code if element exists then element should be show
> but i did not look any thing.
>
> kindly post your thoughts.
>

Reply via email to