html怎么实现鼠标经过时显示按钮?

html-css010

html怎么实现鼠标经过时显示按钮?,第1张

给按钮上绑定一个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>

需要准备的材料分别有:电脑、浏览器、html编辑器。

1、首先,打开html编辑器,新建html文件,例如:index.html,输入问题基础代码。

2、在index.html中的<script>标签中,输入js代码:

$('a').hover(function(){$('img').css('display','block')})

3、浏览器运行index.html页面,此时鼠标移动到超链接上,下面的图片自动显示了出来。