JavaScript怎样实现点击出现效果
先创建一个按钮并且给按钮绑定事件处理函数,在事件处理函数中可以实现元素显示效果。
示例如下:
<!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>Document</title>
<style>
div{
width:200px;
height:200px;
background:red;
display:none;
}
</style>
</head>
<body>
<button onclick="showimg()">显示图片</button>
<div id="test"></div>
<script>
function showimg(){
document.getElementById('test').style.display="block";
}
</script>
</body>
</html>
输出结果:

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

评论(0)