{% load staticfiles %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>covid-19_US_status</title>
<link rel="stylesheet" href=" {% static 'bootstrap-3.3.7-dist/css/bootstrap.css' %}">
<script src="{% static 'bootstrap-3.3.7-dist/js/jquery.min.js' %}"></script>
<script src="{% static 'bootstrap-3.3.7-dist/js/bootstrap.js' %}"></script>
</head>
<body>
<button id='click-button' class="btn btn-primary" style="position: absolute">
简单的按钮
</button>
<script>
$(document).on('mousemove', function(e){
$('#click-button').css({
left: e.pageX,
top: e.pageY
});
});
</script>
</body>
</html>
注意点1:
完成功能的代码如下
<script> $(document).on('mousemove', function(e){ $('#click-button').css({ left: e.pageX, top: e.pageY }); }); </script>
注意点2:
div的
position: absolute