<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>三元表达式</title>
</head>
<body>
<script>
function createDiv(options={}){
let div = document.createElement("div");
div.style.width = options.width ? options.width : "100px";
div.style.height = options.height ? options.height : "100px";
div.style.backgroundColor = options.backgroundColor ? options.backgroundColor : "red";
document.body.appendChild(div);
}
createDiv({width:"200px",height:"200px",backgroundColor:"green"})
</script>
</body>
</html>
JavaScript高级---可爱的三元表达式
猜你喜欢
转载自blog.csdn.net/itwangyang520/article/details/104203306
今日推荐
周排行