UK [klɑ:s nem] US [kl?s nem]

カテゴリ名

JavaScript の className 屬性 構(gòu)文

関數(shù): 要素のクラス屬性を設(shè)定または返します。

構(gòu)文: bodyObject.className=クラス名

JavaScript の className 屬性 例

<html>
<head>
    <meta charset="UTF-8">

</head>
<body id="myid" class="mystyle">

<script type="text/javascript">
    x=document.getElementsByTagName('body')[0];
    document.write("Body CSS class: " + x.className);
    document.write("<br />");
    document.write("An alternate way: ");
    document.write(document.getElementById('myid').className);
</script>

</body>
</html>

インスタンスの実行 ?

[インスタンスの実行] ボタンをクリックしてオンライン インスタンスを表示します