您好,我不知道我的代码有什么问题,有人可以帮助我吗?
animate_demo = function() {
newstyle = {
'font-size': '250%',
'letter-spacing': '0.5em'
}
setup = function() {
jQuery('#demo').click(animate_demo)
jQuery('#animations h2').animate(newstyle, 1000)
}
jQuery(document).ready(setup)
答案 0 :(得分:0)
您需要在.animate
上致电click
。检查以下代码:
var newstyle
var animate_demo = function() {
newstyle = {
'font-size': '250%',
'letter-spacing': '0.5em'
}
$('#animations h2').animate(newstyle, 1000)
}
var setup = function() {
$('#demo').click(animate_demo)
}
$(document).ready(setup)
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="demo">Click me</div>
<div id="animations">
<h2>Text to animate</h2>
</div>