1、JS可以控制web前端的哪两个?
html 和 css
2、写一个普通按钮,使用js设置鼠标移入的时候,弹出“鼠标移入”;
<!DOCTYPE html>
<html>
<head>
<title>按钮示例</title>
<style>
.my-button {
padding: 10px 20px;
background-color: #eaeaea;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<button class="my-button">普通按钮</button>
<script>
const button = document.querySelector('.my-button');
button.addEventListener('mouseover', function() {
alert('鼠标移入');
});
</script>
</body>
</html>
3、写一个提交按钮,使用js设置鼠标移出的时候,弹出“鼠标移出”;
<!DOCTYPE html>
<html>
<head>
<title>提交按钮示例</title>
<style>
.submit-button {
padding: 10px 20px;
background-color: #eaeaea;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<button class="submit-button">提交按钮</button>
<script>
const button = document.querySelector('.submit-button');
button.addEventListener('mouseout', function() {
alert('鼠标移出');
});
</script>
</body>
</html>
标签:03,鼠标,示例,移出,前端,移入,按钮,button From: https://blog.51cto.com/u_16120675/6840797