我想动画输入元素的背景颜色,但它不工作:(jQueryUI的动画(颜色)不工作
的JavaScript(提交时):
function sendImage() {
formularz = $('form#sendImage');
autor = formularz.children('input[name=autor]');
if (autor.val().length < 1 || autor.val().length > 20) {
console.log('start');
autor.animate({
backgroundColor: 'red',
width: '100px',
}, 3000, function() {
console.log('end');
});
}
}
jQuery的liblaries:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<link rel="stylesheet" href="jquery-ui/jquery-ui.min.css">
<script src="jquery-ui/external/jquery/jquery.js"></script>
<script src="jquery-ui/jquery-ui.min.js"></script>
<!-- I tried also this -->
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
在JS功能效果很好 - 在控制台日志中显示,元素的宽度也正在发生变化,但背景色没有,它不控制台显示任何错误
。有什么建议吗?
不是'background-color'而不是'backgroundColor'吗? – 2016-03-05 19:42:02
@noob如果使用属性名称作为文字,那么你不能包含'-',因为它是无效的,所以你需要使用一个字符串。 jQuery非常聪明,它可以接受CSS属性或DOM样式属性名称。因此,在这种情况下,以下任何一个将工作:''background-color'','backgroundColor',''backgroundColor'' –
@Invictus请注意,您包括jQuery和jQueryUI的多个版本 - 您应该删除其中的一个。 –