HTML:
<input id ="input"/>
<div id="box"></div>
CSS:
#box{
width: 100px;
height: 100px;
}
JS:
$('#input').on('focus',function(){
$("#box").css('background', 'linear-gradient(red, transparent)')
})
但是我希望它淡入,所以我尝试了以下方法:
$("#box").css('background', 'linear-gradient(red, transparent)').fadeIn(1500);
还有这个
$('#input').on('focus',function(){
$("#box").fadeIn(1500, function(){
$("#box").css('background', 'linear-gradient(red, transparent)');
});
})
但是两者都不起作用。这是一个小提琴
有任何想法吗?
的fadeIn()
,所以你可以在你的隐藏隐藏要素的作品box
使用hide()
,然后淡入将作品:
$('#input').on('focus',function(){
$("#box").hide().css('background', 'linear-gradient(red, transparent)').fadeIn(1500);
})
希望这可以帮助。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句