Image.className

書式

画像オブジェクト.className

説明

画像(イメージ)オブジェクトのスタイルシートのクラス名を参照/設定します。クラス名はclass属性で指定されたものになります。

サンプルコード [実行]

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<script type="text/javascript"><!--
window.onload = function() {
var txt = document.getElementById("myPhoto").className;
document.getElementById("result").innerHTML = txt;
}
// --></script>
</head>
<body>
<a href="#"><img src="photo.gif" id="myPhoto" class="album"></a>
<div id="result"></div>
</body>
</html>