toggle
?? [?t?gl] US [?tɑ:gl]
n. ??? ?? ?;
jquery ??() ??? ???
??: toggle() ???? ??? ??? ?? ???? ??? ????? ? ? ??? ??? ??? ??? ????? ? ?????. ? ???? ??? ??? hide() ? show() ???? ???? ??? ??? ? ????.
? ? ??? ??? ?? ???? ???: ??? ??? ???? ? ? ??? ?? ??? ??? ?????. ? ? ??? ??? ???? ??() ???? ?? ??? ?????. ?? ?? ??? ? ? ?? ?? ? ?? ??? ? ?? ??? ????, ? ?? ??? ? ?? ??? ????, ? ?? ??? ? ?? ??? ?????. ? ?? ??? ? ?? ??? ?? ???? ?????.
syntax : $ (selector) .toggle (function1 (), function2 (), functionn (), ...)
parameters :
parameters | description |
Function1 () | ?????. ?? ??? ??? ??? ??? ??? ??? ?????. |
function2() | ?????. ??? ??? ??? ??? ??? ??? ?????. |
functionN(),... | ?? ??. ???? ?? ?? ??? ?????. |
Hide() ? Show(): ? ??? ????? ?????. ??? ??? ??? show()? ?????. ??? ???? ?? hide()???. ?? ?? ??? ?????.
??: ??$(selector).toggle(speed,callback)
????:
???? | Description |
speed | ????. ???/?? ??? ??? ?????. ???? "0"???. ??? ?: ???(?: 1500) "??" "??" "??" |
callback | ?? ?????. Toggle() ???? ???? ???? ?????. |
?? ?? ?? ???: ???? ?? ??? ???? ??? ?????.
??: ??$(selector).toggle(switch)
????:
Parameters | Description |
switch | ?????. ??()? ??? ?? ??? ???? ??? ??? ???? ?? ????. true - ?? ?? false - ?? ??? |
jquery ??() ??? ?
<html> <head> <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){ $("button").toggle(function(){ $("body").css("background-color","green");}, function(){ $("body").css("background-color","red");}, function(){ $("body").css("background-color","yellow");} ); }); </script> </head> <body> <button>請點(diǎn)擊這里,來切換不同的背景顏色</button> </body> </html>
??? ????? ??? "???? ??" ??? ?????