add

English [?d] US [?d]

vt.Add; ?? ?? ??... ?? ??(???? ?? ??)

English [klɑ :s] US [kl?s]

n.class; ??

vt....? ?? ???? ??(?? ??, ???); class

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

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

jquery addClass() ??? ???

??: addClass() ???? ??? ??? ?? ??? ???? ?????. ? ??? ?? ??? ??? ???? ?? ?? ??? ??? ??? ?????. ?? ???? ???? ?? ?? ??? ??? ???? ?????.

??: ??$(selector).addClass(???)

????:

ParametersDescription
class ?????. ?? ??? ??? ??? ?????.

??: ??$(selector).addClass(function(index,oldclass))

????:

ParametersDescription
??(???,oldclass) ?????. ??? ?? ??? ??? ??? ???? ??? ?????.
index ????. ???? ??? ?????.
??????. ???? ?? ??? ?????.

jquery addClass() ??? ?

<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:first").addClass("intro");
  });
});
</script>
<style type="text/css">
.intro
{
font-size:120%;
color:red;
}
</style>
</head>

<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>向第一個 p 元素添加一個類</button>
</body>
</html>
???? ?? ?

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