0
点赞
收藏
分享

微信扫一扫

标签的样式与类的操作 js 230209

全栈顾问 2023-02-09 阅读 50

样式操作


标签的样式与类的操作 js 230209_html


dom标签对象操作样式

style是样式对象


示例


<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>

<button>我要留言</button>

<input type="text" id="msg" value="请输入内容">

<script>
var btn = document.querySelector("button")
var msg = document.querySelector("#msg")

btn.onclick = function () {
msg.style.height = "300px"
msg.style.backgroundColor = "gold"

}
</script>

</body>
</html>



操作类

标签的样式与类的操作 js 230209_scala_02



举报

相关推荐

0 条评论