您将需要为鼠标事件编写一个侦听器。就像是:
HTML:
<element onmouseover="myScript"> <script> function mouseOver() { <!-- Script goes here--> } function mouseOut() { <!-- Script goes here--> } </script>
JS:
object.onmouseover = function(){myScript};
或者
object.addEventListener("mouseover", myScript);
Bodymovin 使用 JavaScript 启动动画,因此只需将动画设置为在鼠标悬停或单击鼠标时搜索栏展开后停止,然后将动画设置为在鼠标移出时向后播放。
另一个例子: 来源:https ://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_onmouseover_html
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").hover(function(){
$(this).css("background-color", "yellow");
}, function(){
$(this).css("background-color", "white");
});
});
</script>
</head>
<body>
<p>Hover the mouse pointer over this paragraph.</p>
</body>
</html>
我希望这能让您知道该怎么做并且对您有所帮助!