본문 바로가기

개발하자/자바스크립트

테두리 바꾸기(borderStyle)

sol1)

<html>
 <head>
 <style type="text/css">
 input {
 width:200px;
 height:200px;
 border-width:5px;
 border-style:solid;
 border-color:black;
 }
 </style>
 <script>
 function d(){
 a.style.borderStyle=a.value;
 }
 function e(){
 b.style.borderStyle=b.value;
 }
 function f(){
 c.style.borderStyle=c.value;
 }
 </script>
 </head>
 <body>
 <input type="button" value="dashed" id="a" onclick="d()">
 <input type="button" value="dotted" id="b" onclick="e()">
 <input type="button" value="double" id="c" onclick="f()">
 </body>
</html>

 

sol2)

<html>
 <head>
 <style type="text/css">
 input {
 width:200px;
 height:200px;
 border-width:5px;
 border-style:solid;
 border-color:black;
 }
 </style>
 <script>
 function f(n){
 n.style.borderStyle=n.value;
 }
 </script>
 </head>
 <body>
 <input type="button" value="dashed" onclick="f(this)">
 <input type="button" value="dotted"  onclick="f(this)">
 <input type="button" value="double" onclick="f(this)">
 </body>
</html>

'개발하자 > 자바스크립트' 카테고리의 다른 글

링크  (0) 2015.02.10
html 리스트  (0) 2015.02.10
focus()  (0) 2015.02.07
지우기,복사  (0) 2015.02.07
배열사용  (0) 2015.02.07