Prototype-number-tocolorpart
提供:Dev Guides
プロトタイプ-toColorPart()メソッド
このメソッドは、数値の2桁の16進数表現を生成するため、[0..255]の範囲にあると想定されます。
この関数は、CSSカラー文字列を作成するのに便利です。
構文
number.toColorPart();
戻り値
カプセル化された番号。
例
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
alert("(128).toColorPart() : " + (128).toColorPart() );
alert("(10).toColorPart() : " + (10).toColorPart() );
}
</script>
</head>
<body>
<p>Click the button to see the result.</p>
<br/>
<br/>
<input type = "button" value = "Result" onclick = "showResult();"/>
</body>
</html>