当光标越过它时,我试图使按钮高亮显示 html是:
<head>
<script src="jquery.js></script>
<scrips src="index.html"></script>
</head>
和index.js中的js
$(".button").mouseenter(function(){
$(".button).css("background-color", "cyan");
$(".button).css("color", "white");
});
答案 0 :(得分:1)
$(".button").mouseenter(function(){
$(".button").css("background-color", "cyan");
$(".button").css("color", "white");
});
答案 1 :(得分:0)
jQuery和html中缺少引号
HTML
<html>
<head>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
</head>
<body>
<button class="button" type="button">Change my color</button>
<script src="custom.js" type="text/javascript"></script>
</body>
</html>
custom.js
$(".button").mouseenter(function(){
$(".button").css("background-color", "cyan");
$(".button").css("color", "white");
});
答案 2 :(得分:0)
$(".button").mouseenter(()=>{$(".button")
.css({"background-color":"cyan","color":"black"});
});
$(".button").mouseleave(()=>{$(".button")
.css({"background-color":"#0084ff","color":"white"});
});