Hi Rick,
I'm the author of that blog entry.
The problem is that you don't close the jquery.js <script>. You need
to do that first, and then, if you want your example code to be in
the <head>, open another <script>. Try this:
<script type="text/javascript" src="/scripts/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#slickbox').hide();
$('#slick-toggle').click(function() {
$('#slickbox').toggle(400);
return false;
});
});
</script>
And yes, Christof is right -- we don't need the "a" in that selector.
Cheers,
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Jan 25, 2007, at 1:53 PM, Rick Faircloth wrote:
Hi, Christof...
Thanks for the suggestion, but that didn't work either...same
response as
before.
I wonder...on the source of the demo page showing this effect,
there is
reference
to both the jquery.js file and another file, examples.js, which I
don't have
access to
or reference in my code to.
<script src="/scripts/jquery.js" type="text/javascript"></script>
<script src="/scripts/examples.js" type="text/javascript"></script>
I wonder if the lack of the second src reference in my code
is preventing this example from working. I was assuming that all the
functionality needed would be contained within jquery.js, itself.
If the author of the examples for
http://www.learningjquery.com/2006/09/slicker-show-and-hide
reads this, would they please make the "examples.js" code
available, if it's
needed?
Rick
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:discuss-
[EMAIL PROTECTED] On
Behalf Of Christof Donat
Sent: Thursday, January 25, 2007 12:40 PM
To: jQuery Discussion.
Subject: Re: [jQuery] Why won't this code work?
Hi,
$(document).ready(function() {
// hides the slickbox as soon as the DOM is ready
// (a little sooner than page load)
$('#slickbox').hide();
});
// toggles the slickbox on clicking the noted link
$('a#slick-toggle').click(function() {
$('#slickbox').toggle(400);
return false;
});
try it this way:
$(document).ready(function() {
$('#slickbox').hide();
$('a#slick-toggle').click(function() {
$('#slickbox').toggle(400);
return false;
});
});
Then the Element behind $('a#slick-toggle') does exist when you try
to use
it.
BTW.: If you are shure, that the id "slick-toggle" is alway a <a>-
element,
you
will be off better with $('#slick-toggle'). In that case jQuery can
simply
use document.getElementById(). I am not shure about jQuery 1.1, but
older
Versions with $('a#slick-toggle') would search the whole document
tree for
<a>-tags and check if they have the given id. That is of course a lot
slower.
You can even spare another jquery query, but don't expect too much
speed up
from that:
$(document).ready(function() {
var sl = $('#slickbox').hide();
$('a#slick-toggle').click(function() {
sl.toggle(400);
return false;
});
});
Since you already use an id here, the second query doesn't really
take much
time.
Christof
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/