[jQuery] 1.0a toggle() function

[jQuery] 1.0a toggle() function

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=218073915-11072006><FONT face=Arial color=#0000ff
size=2>Myles...</FONT></SPAN></DIV>
<DIV><SPAN class=218073915-11072006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=218073915-11072006><FONT face=Arial color=#0000ff size=2>How
does the function get triggered? You don't have an onclick event on the HREF
tag.</FONT></SPAN></DIV>
<P><FONT size=2><!----------------//------<BR>andy matthews<BR>web
developer<BR>certified advanced coldfusion programmer<BR>ICGLink,
Inc.<BR>andy@icglink.com<BR>615.370.1530
x737<BR>--------------//---------></FONT> </P>
<BLOCKQUOTE>
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> discuss-bounces@jquery.com
[mailto:discuss-bounces@jquery.com]<B>On Behalf Of </B>Myles
Angell<BR><B>Sent:</B> Tuesday, July 11, 2006 9:46 AM<BR><B>To:</B> jQuery
Discussion.<BR><B>Subject:</B> Re: [jQuery] 1.0a toggle()
function<BR><BR></FONT></DIV><SPAN class=gmail_quote></SPAN>
<DIV>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Hi
there, I'm new to jQuery but am excited to start working with it.
</BLOCKQUOTE>
<DIV><BR>Welcome, jQuery is a fun place to be. </DIV><BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">My
issue lies with the new toggle() function that works as such:
<BR>"$().toggle(function, function): Whenever a matched element
is<BR>clicked, the first function is fired, when clicked again, the
second<BR>is fired, all subsequent clicks continue to rotate through the
two<BR>functions." </BLOCKQUOTE>
<DIV><BR>The problem lies in how you set up the event, the only code you need
is:<BR><BR>   
$(document).ready(function(){<BR>       
$('div').hide();<BR>       
$('#button').toggle(<BR>       
    function(){    $('div').slideDown('normal')
}, <BR>           
function(){    $('div').slideUp('normal')
}<BR>        );<BR>   
});<BR><BR>With the HTML reduced to: <BR><a id="button" href="#">Toggle
box display</a><BR> <BR></DIV></DIV>Hope this
helps!<BR><BR>Myles<BR></BLOCKQUOTE></BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/



















































    • Topic Participants

    • andy