toggle

英[?t?gl]   美[?tɑ:gl]

n. ??? ??; ?? ?

v. ] 美[kl?s]

n.class; grade; ????vt.... ?? ???... ????? ???? ?????

adj .?? ??, ???, ???

vi.... ????(?? ??)? ??, ?? ????(?? ??)? ???

jquery ?????() ??? ???

??: toggleClass()? ??? ??? ????? ???? ?? ??? ???? ?????. ? ???? ? ??? ??? ???? ?????. ???? ???? ??? ????, ???? ??? ?????. ?? ?? ???? ???. ??? "switch" ????? ???? ???? ????? ??? ??? ??? ? ????.

??: ??$(selector).toggleClass(class,switch)

????:

???? Description
class ?????. ???? ??? ?? ?? ?? ??? ?????. ?? ???? ???? ?? ?? ??? ???? ??? ??? ?????.
??? ????. ?? ?. ???? ????? ???? ??? ?????.

??? ???? ??? ?? ??: $(selector).toggleClass(function(index,class),switch)

????:

ParametersDescription
?? (??,???) ?????. ????? ???? ?? ?? ??? ??? ??? ???? ??? ?????.
index ????. ???? ??? ??? ?????.
??????. ???? ?? ???? ?????.
??? ????. ?? ?. ???? ??(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").click(function(){
    $("p").toggleClass("main");
  });
});
</script>
<style type="text/css">
.main
{
font-size:120%;
color:red;
}
</style>
</head>

<body>
<h1 id="h1">This is a heading</h1>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button class="btn1">切換段落的 "main" 類</button>
</body>
</html>
???? ?? ?

??? ????? ??? "???? ??" ??? ?????