1、首先,打开html编辑器,新建html文件,例如:index.html。
2、在index.html中的<script>标签中,输入js代码:
$('button').click(function () {$('div').css('display', 'block')})
3、浏览器运行index.html页面,会有个显示按钮。
4、点击显示按钮,此时被隐藏的内容显示了出来。
给按钮上绑定一个onclick事件,同时置一个状态值,状态值为true时显示按钮。
具体代码如下:
<html>
<head>
<script type="text/javascript" src="https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/static/protocol/https/jquery/jquery-1.10.2.min_f2fb5194.js"></script>
</head>
<body>
<button id="a">btn1</button>
<button id="b">btn2</button>
<script>
$(document).ready(function()
{
$("#a").click(function()
{
$("#a").hide()
})
$("#b").click(function()
{
$("#a").show()
}
)
})
</script>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)