関数の引数に配列を利用

下のSampleのスタイルを変更します  

Sample

Sample Source......................................................................>>>

<script language="JavaScript"><!--
function Test1(colorArray){
  document.getElementById("samp").style.color = colorArray[0];
  document.getElementById("samp").style.backgroundColor = colorArray[1];
  document.getElementById("samp").style.borderColor = colorArray[2];
  document.getElementById("samp").style.borderWidth = colorArray[3];
}

//--></script>
</head>

<body>
  <button onclick="Test1(['red','mistyrose','blue',3])">Style 1</button>
  <button onclick="Test1(['blue','lavender','red',2])">Style 2</button>
  <button onclick="Test1(['black','white','green',1])">Style 3</button>

<h5 id="samp">Sample</h5>  


(最終更新:12/12/23)
フレーム構成になっています・・・<[ホーム] >> [HTML整理ノート]>