スタイル属性を取得する

書式

animeObj.getAttribute(attrName)

animeObj : アニメーションオブジェクト
attrName : 属性名

説明

 スタイル属性を取得するにはアニメーションオブジェクトに対してgetAttribute()を使います。パラメータには取得したいスタイルシートの属性名を指定します。

サンプルコード [実行]

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="main.css" type="text/css" media="all">
<script type="text/javascript" src="yahoo.js"></script>
<script type="text/javascript" src="event.js"></script>
<script type="text/javascript" src="dom.js"></script>
<script type="text/javascript" src="animation.js"></script>
<script type="text/javascript"><!--
function startAnime(aElement, attr){
var boxObj = new YAHOO.util.Anim(aElement, attr);
YAHOO.util.Dom.get("result").innerHTML = boxObj.getAttribute("width");
boxObj.animate();
}
// --></script>
</head>
<body>
<h1>スタイル属性を取得</h1>
<form>
<input type="button" value="Box 1のアニメ開始" onClick="startAnime('box1', { width: { from:100, to:220 }})"><br>
<input type="button" value="Box 2のアニメ開始" onClick="startAnime('box2',{ width: { from:100, to:400 }})"><br>
</form>
<div id="result"></div>
<div id="box1">[Box1 ]</div>
<div id="box2">[Box2 ]</div>
</body>
</html>