[Javascript] jQuery: toggle() method not working

Andre Polykanine andre at oire.org
Tue Nov 16 10:47:16 CST 2010


Hello Hassan,

Thanks, placing of the script after the mark-up helped.
Unfortunately I don't use FireBug since (however it pretends to be
accessible) I don't manage to use it (I'm a screenreader user).
-- 
With best regards from Ukraine,
Andre
Skype: Francophile
Twitter: http://twitter.com/m_elensule
Facebook: http://facebook.com/menelion

----- Original message -----
From: Hassan Schroeder <hassan at webtuitive.com>
To: JavaScript List <javascript at lists.evolt.org>
Date: Tuesday, November 16, 2010, 6:01:39 PM
Subject: [Javascript] jQuery: toggle() method not working

On 11/16/10 7:27 AM, Andre Polykanine wrote:

> <script type="text/javascript">
> $("#showBookmark").click(function(e) {
> $("#bookmark").toggle();
> e.preventDefault();
> });
> </script>
> <a href="#" class="menu" id="showBookmark">Show/hide social bookmarks</a>
> <div id="bookmark" class="main" style="display:none"><?=$knopka?></div>
>
> That doesn't work. What am I doing wrong?

Defining "doesn't work" would be a good idea -- are you using e.g.
Firebug and seeing an error, or _______ ?

Regardless, if the above is a literal copy/paste, you're trying to
assign an event handler to an object that doesn't yet exist. Move
the script block after the markup, or enclose the js assignment in
a document.ready block.

HTH,
-- 
Hassan Schroeder ----------------------------- hassan at webtuitive.com
webtuitive design ===  (+1) 408-621-3445   === http://webtuitive.com
twitter: @hassan
                           dream.  code.
_______________________________________________
Javascript mailing list
Javascript at lists.evolt.org
http://lists.evolt.org/mailman/listinfo/javascript



More information about the Javascript mailing list