<html>
<head>
<script>
window.onload=function(){
b.onclick=function(){
t.value.style.background="red";
}
}
</script>
</head>
<body>
<input type="text" id="t">
<input type="button" id="b" value="바꾸기">
<input type="button" id="b1">
<input type="button" id="b2">
</body>
</html>
<html>
<head>
<script>
window.onload=function(){
b.onclick=function(){
var obj=document.getElementById(t.value);
obj.style.background="red";
}
}
</script>
</head>
<body>
<input type="text" id="t">
<input type="button" id="b" value="바꾸기">
<input type="button" id="b1">
<input type="button" id="b2">
</body>
</html>
'개발하자 > 자바스크립트' 카테고리의 다른 글
select 한 option 값을 이용해서 배경색바꾸기 onchange사용의 예 (0) | 2015.02.26 |
---|---|
주소선택해서 이전창으로 불러오기 (0) | 2015.02.26 |
window.open(새창띄우기) (0) | 2015.02.26 |
onfocus,onblur (0) | 2015.02.26 |
과제3(마우스클릭 좌표값을 이용해 div출력하기) (0) | 2015.02.24 |