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="curl">URL</label>
    <input id="curl" name="url" size="25" class="required"  type="text" />
  </p>
</div>
</body>
</html>



Reply via email to