JavaScript에서 모든 border-radius 속성을 설정하려면 borderRadius 재산. 이것을 이용하여 border-radius 속성을 한번에 설정합니다.
예시
다음 코드를 실행하여 네 가지 border-radius 속성을 모두 설정하는 방법을 배울 수 있습니다 -
<!DOCTYPE html>
<html>
<head>
<style>
#box {
border: thick solid gray;
width: 200px;
height: 200px
}
</style>
</head>
<body>
<div id="box">Demo Text</div>
<br><br>
<button type="button" onclick="display()">Add border radius</button>
<script>
function display() {
document.getElementById("box").style.borderRadius = "20px";
}
</script>
</body>
</html>