[jQuery] Re: hiding a div on document ready?

2008-06-08 Thread Michael Geary
There are a couple of typos in that .css({ display:none; }) call: none needs
to be quoted, and the semicolon shouldn't be there.
 
Anyway, typos aside, it's not really a matter of being correct or not. Each
of the following sets the same CSS style:
 
$('#durl').hide();
 
$('#durl').css( 'display', 'none' );
 
$('#durl').css({ display: 'none' });
 
$('#durl')[0].style.display = 'none';
 
The .hide() method does a little extra work before setting the style, but
it's just bookkeeping stuff to help .hide() and .show() work together. The
net effect will be the same, setting the element's style.display attribute
to 'none'.
 
.hide() is certainly the easiest way to do it, though.
 
-Mike



  _  

From: Kevin Pepperman

Giuliano showed you the correct way to hide the div.
 
But If you do want to add that css to the element it would be used like
this.
 
$(document).ready(function(){
$(#durl).css({ display:none;  });
 });



[jQuery] Re: hiding a div on document ready?

2008-06-07 Thread Giuliano Marcangelo
make sure you use the* # *sign to signify that it is an element with
an *id*of durl, and then
*hide *it 

$(document).ready(function(){
   $(*#*durl).hide();
   });

2008/6/7 mark [EMAIL PROTECTED]:


 hi, am just beginning with jquery, and i want to hide a div to begin.
 i tried this and it doesnt work and it is not hidden. do you know what
 is wrong?
 i also tried, $(durl).css(display,none);

 is this wrong?
 thanks



 html
 head
  script type=text/javascript
 src=http://jqueryjs.googlecode.com/files/jquery-1.2.6.pack.js;/script
  script type=text/javascript
$(document).ready(function(){
$(durl).style.display=none;
});
  /script
 /head
 body

 div id=durl 
   p
 label for=curlURL/label
 input id=curl name=url size=25 class=required  type=text /
   /p
 /div
 /body
 /html



[jQuery] Re: hiding a div on document ready?

2008-06-07 Thread Michael Geary
Just to clarify, the .css('display','none') would have worked fine - .hide()
is just a shorter way of doing exactly the same thing. It was the $('durl')
that tripped you up - that tries to select all elements with a tagname of
'durl'.
 
Here's a debugging tip. Add this bit of code:
 
$(function() {
debugger;
});
 
and load your page in Firefox with Firebug enabled. (The $(function() part
is just a shorter way of doing $(document).ready( function().)
 
Firebug should stop at the debugger; statement. Click in the Firebug console
command line (bottom of the window after ) and start poking around.
 
First, just enter your original query, without the .css() or .hide() method
call:
 
$('durl')
 
You'll see that it displays an empty array, meaning that you selected no
elements at all.
 
Now try it with the # added (hit the up arrow key to bring back the previous
command and edit it):
 
$('#durl')
 
This time you should see an array with the expected element in it.
 
Now append .hide() to the command (use the up-arrow trick again) and hit
Enter one more time:
 
$('#durl').hide()
 
And presto! Your id=durl element is hidden.
 
You can track down a lot of problems this way. Just keep in mind the
two-part nature of every jQuery operation: first select, then act on the
selection. So the first step, as in these examples, to make sure your
selector is select what you expect.
 
-Mike
 



  _  

From: Giuliano Marcangelo

make sure you use the # sign to signify that it is an element with an id of
durl, and then hide it 

$(document).ready(function(){
   $(#durl).hide();
   });


2008/6/7 mark [EMAIL PROTECTED]:



hi, am just beginning with jquery, and i want to hide a div to begin.
i tried this and it doesnt work and it is not hidden. do you know what
is wrong?
i also tried, $(durl).css(display,none);

is this wrong?
thanks



html
head
 script type=text/javascript
src=http://jqueryjs.googlecode.com/files/jquery-1.2.6.pack.js;/script
 script type=text/javascript
   $(document).ready(function(){
   $(durl).style.display=none;
   });
 /script
/head
body

div id=durl 
  p
label for=curlURL/label
input id=curl name=url size=25 class=required  type=text /
  /p
/div
/body
/html





[jQuery] Re: hiding a div on document ready?

2008-06-07 Thread Kevin Pepperman
Giuliano showed you the correct way to hide the div.

But If you do want to add that css to the element it would be used like
this.

$(document).ready(function(){
$(#durl).css({ display:none;  });
 });


On Sat, Jun 7, 2008 at 3:50 PM, Giuliano Marcangelo 
[EMAIL PROTECTED] wrote:

 make sure you use the* # *sign to signify that it is an element with an *
 id* of durl, and then *hide *it 

 $(document).ready(function(){
$(*#*durl).hide();
});

 2008/6/7 mark [EMAIL PROTECTED]:


 hi, am just beginning with jquery, and i want to hide a div to begin.
 i tried this and it doesnt work and it is not hidden. do you know what
 is wrong?
 i also tried, $(durl).css(display,none);

 is this wrong?
 thanks



 html
 head
  script type=text/javascript
 src=http://jqueryjs.googlecode.com/files/jquery-1.2.6.pack.js;/script
  script type=text/javascript
$(document).ready(function(){
$(durl).style.display=none;
});
  /script
 /head
 body

 div id=durl 
   p
 label for=curlURL/label
 input id=curl name=url size=25 class=required  type=text /
   /p
 /div
 /body
 /html