[jQuery] bind two events to same function

[jQuery] bind two events to same function

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v =
"urn:schemas-microsoft-com:vml" xmlns:o =
"urn:schemas-microsoft-com:office:office" xmlns:w =
"urn:schemas-microsoft-com:office:word" xmlns:st1 =
"urn:schemas-microsoft-com:office:smarttags" xmlns:ns0 =
"urn:schemas-microsoft-com:office:smarttags"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.3059" name=GENERATOR><!--[if !mso]>
<STYLE>v\:* {
BEHAVIOR: url(#default#VML)
}
o\:* {
BEHAVIOR: url(#default#VML)
}
w\:* {
BEHAVIOR: url(#default#VML)
}
.shape {
BEHAVIOR: url(#default#VML)
}
</STYLE>
<![endif]--><o:SmartTagType name="State"
namespaceuri="urn:schemas-microsoft-com:office:smarttags"></o:SmartTagType><o:SmartTagType
name="City"
namespaceuri="urn:schemas-microsoft-com:office:smarttags"></o:SmartTagType><o:SmartTagType
name="place"
namespaceuri="urn:schemas-microsoft-com:office:smarttags"></o:SmartTagType><o:SmartTagType
name="PersonName"
namespaceuri="urn:schemas-microsoft-com:office:smarttags"></o:SmartTagType><!--[if !mso]>
<STYLE>
st1\:*{behavior:url(#default#ieooui) }
</STYLE>
<![endif]-->
<STYLE>
<!--
/* Font Definitions */
@font-face
{font-family:"Monotype Corsiva";
panose-1:3 1 1 1 1 2 1 1 1 1;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}
p.MsoEnvelopeAddress, li.MsoEnvelopeAddress, div.MsoEnvelopeAddress
{margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:2.0in;
margin-bottom:.0001pt;
mso-element:frame;
font-size:14.0pt;
font-family:"Monotype Corsiva";
font-weight:bold;
font-style:italic;}
p.MsoEnvelopeReturn, li.MsoEnvelopeReturn, div.MsoEnvelopeReturn
{margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Monotype Corsiva";
font-style:italic;}
a:link, span.MsoHyperlink
{color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{color:blue;
text-decoration:underline;}
span.EmailStyle20
{mso-style-type:personal-reply;
font-family:Verdana;
color:black;
font-weight:normal;
font-style:normal;
text-decoration:none none;}
@page Section1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
{page:Section1;}
-->
</STYLE>
</HEAD>
<BODY lang=EN-US vLink=blue link=blue bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Actually I did end up using hover(), it works
better for what I'm trying to do...so hand over the dunce cap!</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>But now I also know how to bind the same function
to multiple events if I ever want to do that...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>-- Josh</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=david@brilliantlemming.com
href="mailto:david@brilliantlemming.com">David Dexter</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=discuss@jquery.com
href="mailto:discuss@jquery.com">'jQuery Discussion'</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Tuesday, March 27, 2007 3:21
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [jQuery] bind two events to
same function</DIV>
<DIV><BR></DIV>
<DIV class=Section1>
<P class=MsoNormal><FONT face=Verdana color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana">I have my dunce
capÂ… which corner do I go sit in?<o:p></o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face=Verdana color=black size=2><SPAN
style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Verdana"><o:p> </o:p></SPAN></FONT></P>
<DIV>
<P class=MsoNormal
style="mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"><B><FONT
face=Verdana size=2><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Verdana"><ns0:PersonName
w:endInsDate="2007-03-27T15:20:00Z" w:endInsAuthor="David Dexter"
w:insDate="2007-03-27T15:20:00Z" w:insAuthor="David Dexter"><ns0:PersonName
w:endInsDate="2007-03-27T15:20:00Z" w:endInsAuthor="David Dexter"
w:insDate="2007-03-27T15:20:00Z" w:insAuthor="David Dexter"><st1:PersonName
w:st="on"><FONT color=#336699><SPAN style="COLOR: #336699">David
Dexter</SPAN></FONT></st1:PersonName></ns0:PersonName></U2:PERSONNAME><FONT
color=silver><SPAN style="COLOR: silver">   | 
brilliantlemming.com  |  </SPAN></FONT><ns0:place
w:endInsDate="2007-03-27T15:20:00Z" w:endInsAuthor="David Dexter"
w:insDate="2007-03-27T15:20:00Z" w:insAuthor="David Dexter"><ns0:City
w:endInsDate="2007-03-27T15:20:00Z" w:endInsAuthor="David Dexter"
w:insDate="2007-03-27T15:20:00Z" w:insAuthor="David Dexter"><st1:place
w:st="on"><st1:City w:st="on"><FONT color=silver><SPAN
style="COLOR: silver">Brentwood</SPAN></FONT></st1:City></ns0:City></st1:place><FONT
color=silver><SPAN style="COLOR: silver">, </SPAN></FONT><ns0:State
w:endInsDate="2007-03-27T15:20:00Z" w:endInsAuthor="David Dexter"
w:insDate="2007-03-27T15:20:00Z" w:insAuthor="David Dexter"><st1:State
w:st="on"><FONT color=silver><SPAN
style="COLOR: silver">CA</SPAN></FONT></st1:State></ns0:State></ns0:place><FONT
color=silver><SPAN style="COLOR: silver">  | 
310.414.0949</SPAN></FONT></ns0:PersonName></SPAN></FONT></B><B><FONT
face=Verdana color=silver size=2><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; COLOR: silver; FONT-FAMILY: Verdana"><o:p></o:p></SPAN></FONT></B></P></DIV>
<DIV>
<DIV class=MsoNormal style="TEXT-ALIGN: center" align=center><FONT
face="Times New Roman" size=3><SPAN style="FONT-SIZE: 12pt">
<HR tabIndex=-1 align=center width="100%" SIZE=2>
</SPAN></FONT></DIV>
<P class=MsoNormal><B><FONT face=Tahoma size=2><SPAN
style="FONT-WEIGHT: bold; FONT-SIZE: 10pt; FONT-FAMILY: Tahoma">From:</SPAN></FONT></B><FONT
face=Tahoma size=2><SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: Tahoma"> <A
href="mailto:discuss-bounces@jquery.com">discuss-bounces@jquery.com</A>
[mailto:discuss-bounces@jquery.com] <B><SPAN style="FONT-WEIGHT: bold">On
Behalf Of </SPAN></B>Aaron Heimlich<BR><B><SPAN
style="FONT-WEIGHT: bold">Sent:</SPAN></B> Tuesday, March 27, 2007 3:02
PM<BR><B><SPAN style="FONT-WEIGHT: bold">To:</SPAN></B> jQuery
Discussion<BR><B><SPAN style="FONT-WEIGHT: bold">Subject:</SPAN></B> Re:
[jQuery] bind two events to same function</SPAN></FONT><o:p></o:p></P></DIV>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><o:p> </o:p></SPAN></FONT></P>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">On 3/27/07, <B><SPAN style="FONT-WEIGHT: bold">David
Dexter</SPAN></B> <<A
href="mailto:david@brilliantlemming.com">david@brilliantlemming.com</A>>
wrote:<o:p></o:p></SPAN></FONT></P>
<DIV>
<BLOCKQUOTE
style="BORDER-RIGHT: medium none; PADDING-RIGHT: 0in; BORDER-TOP: medium none; PADDING-LEFT: 6pt; PADDING-BOTTOM: 0in; MARGIN-LEFT: 4.8pt; BORDER-LEFT: #cccccc 1pt solid; MARGIN-RIGHT: 0in; PADDING-TOP: 0in; BORDER-BOTTOM: medium none">
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt">Have a look at the hover() function it does exactly
what you are looking<BR>for.<o:p></o:p></SPAN></FONT></P></BLOCKQUOTE></DIV>
<P class=MsoNormal><FONT face="Times New Roman" size=3><SPAN
style="FONT-SIZE: 12pt"><BR>Actually, it doesn't. hover() expects two
different functions. From the API docs:<BR><BR>"Whenever the mouse cursor is
moved over a matched element, the first specified function is fired. Whenever
the mouse moves off of the element, the second specified function fires."
<BR><BR>Source: <A
href="http://docs.jquery.com/Events#hover.28_over.2C_out_.29">http://docs.jquery.com/Events#hover.28_over.2C_out_.29</A><BR><BR>What
Josh wants to do is bind the *exact same function* to do different events
(which is what I showed him how to do). <BR><BR>-- <BR>Aaron Heimlich<BR>Web
Developer<BR><A
href="mailto:aaron.heimlich@gmail.com">aaron.heimlich@gmail.com</A><BR><A
href="http://aheimlich.freepgs.com">http://aheimlich.freepgs.com</A>
<o:p></o:p></SPAN></FONT></P></DIV>
<P>
<HR>
<P></P>_______________________________________________<BR>jQuery mailing
list<BR>discuss@jquery.com<BR>http://jquery.com/discuss/<BR></BLOCKQUOTE></BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/



































































































































































































    • Topic Participants

    • josh