2 개의 이미지와 4 개의 버튼이 있습니다. 단추를 클릭하면 단추의 색상과 배경의 배경색을 변경하고 싶습니다.어떻게하면 자바 스크립트에서 OK 버튼을 만들 수 있습니까?
function button_fn(Obj)
{
document.getElementById("div_field").style = "background-color:" + Obj.name;
document.getElementById("img_id").style = "border-color:" + Obj.name;
}
</script>
<body>
<fieldset>
<legend > background color change:</legend>
<div id="div_field">
<img src="home.png" name="img_png" width="200" />
</div>
<form >
<input type="button" name="red" value="Red" id="but1_id" onclick= "button_fn(this)"/>
<input type="button" name="green" value="Green" id="but2_id" onclick="button_fn(this)"/>
<input type="button" name="blue" value="Blue" id="but3_id" onclick="button_fn(this)"/>
<input type="button" name="confirm" value="OK" id="confirm_id" onclick="button_fn(this)"/>
</form>
</fieldset>
<div id="div_image" >
<img src="service2.jpg" id="img_id" name="imag" width="200"border="40" />
</div>