我只是在测试 jQuery,这可能很简单,但我想弄清楚这里出了什么问题。
我只想让按钮稍微淡出。
$(document).ready(function(){
$('button').mouseenter({
$('button').fadeTo('slow',1);
}};
});
button {
border:2px solid #27ae60;
border-radius:5px;
height:50px;
width:125px;;
background-color:#2ecc71;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>title</title>
</head>
<body>
<button>Click Me</button>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
</body>
</html>
谢谢!
最佳答案
您的按钮当前的不透明度为 1,并且您的淡入淡出效果不会改变它。你也有一些错误的括号。这样的事情会起作用:
$(document).ready(function(){
$('button').on('mouseenter', function(){
$('button').fadeTo('slow',0);
});
});
在这里查看它的工作情况:https://jsfiddle.net/0Lqcnbv5/
希望对您有所帮助!
关于javascript - 为什么这个 jQuery 脚本不起作用?我看不出有什么不对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35703840/