【发布时间】:2017-11-04 17:03:13
【问题描述】:
我正在尝试更改单击 div 上的框阴影这是我的代码
index.html
<html>
<head>
<script src="jquery-3.2.1.min.js"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="ttt"></div>
<script src="script.js"></script>
</body>
</html>
script.js
$(document).ready(function () {
var state = false;
$("#ttt").click(function () {
if (state) {
$("#ttt").animate({
'boxShadowX': '10px',
'boxShadowY': '10px',
'boxShadowBlur': '20px'
});
} else {
$("#ttt").animate({
'boxShadowX': '3px',
'boxShadowY': '3px',
'boxShadowBlur': '3px'
});
}
console.log(state);
state = !state;
});
});
style.css
#ttt{
padding-left: 100px;
padding-top: 100px;
padding-right: 100px;
padding-bottom: 100px;
width: 100px;
height: 100px;
background-color: red;
border-radius: 10px;
box-shadow: 10px 10px 5px #888888;
}
当鼠标点击它时,我如何使用 jquery 来切换 box-show 以将动画从完全可见变为细?
【问题讨论】:
标签: javascript jquery html css