Javascript 使用Jquery动画突出显示边框颜色?
当单击添加动画链接时,我想使用动画功能突出显示文本字段的边框Javascript 使用Jquery动画突出显示边框颜色?,javascript,jquery,html,css,animation,Javascript,Jquery,Html,Css,Animation,当单击添加动画链接时,我想使用动画功能突出显示文本字段的边框 $(".add_animation").click(function (){ $("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear"); }); 像这样: $(".add_animation").click(function (){ $("#search").focus().animate({ "bac
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
像这样:
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
Js在这里拉小提琴:
.field_style { width:400px; }
.styling { color:red; }
.test_field_style {
border-color: #6EA2DE;
box-shadow: 0 0 10px #6EA2DE;
width:400px;
}
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
HTML:
<div>
<p>
<input type="text" name="search" id="search" placeholder="Search for people...." class="field_style">
</p>
<p> <a href="javascript:void(0);" class="add_animation">Add Animation</a> </p>
</div>
<p class="styling"> I want it like this when click on Add Animation :</p>
<div>
<p>
<input type="text" name="test_search" id="test_search" placeholder="Search for people...." class="test_field_style">
</p>
</div>
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
Jquery:
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
尝试使用此插件:并附加:
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
<script src="http://www.bitstorm.org/jquery/color-animation/jquery.animate-colors-min.js"></script>
这里举一个例子:
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
默认情况下,jQuery animate的backgroundColor
不是可设置动画的属性。通常,它无法设置颜色的动画。虽然简单的CSS转换没有得到广泛的支持(IE9-will不支持),但使用它们会有更好的效果
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
.8s对于动画来说有点长。您有两个不同的选项。最好的性能肯定是CSS:
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
JS:
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
$(".add_animation").click(function (){
$("#search").focus(function() {
$(this).css({backgroundColor: '#B6DADA'});
}).blur(function() {
$(this).css({backgroundColor: '#fff'});
}).focus();
});
CSS:
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
#search {
-webkit-transition: .8s background linear;
-moz-transition: .8s background linear;
-ms-transition: .8s background linear;
-o-transition: .8s background linear;
transition: .8s background linear;
}
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
另一种方法是使用jQuery插件或其他东西(我最喜欢的名字叫jQuery)来设置颜色的动画
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});
$(".add_animation").click(function (){
$("#search").focus(function() {
$(this).animate({backgroundColor: '#B6DADA'}, 800, 'linear');
}).blur(function() {
$(this).animate({backgroundColor: '#fff'}, 800, 'linear');
}).focus();
});
你不能用jQuery设置颜色或框阴影的动画,至少不能不使用step方法和jQuery UI等。但是你可以做其他人都在做的事情,使用CSS3->好吧,它工作正常,但是当这个文本字段失去焦点时,它应该删除类。只需添加->@adeneo,工作正常,背景色又是什么呢?如果你不想添加背景色,只需将其添加到类->边框仍未高亮显示只需将borderColor:“#ccc”
或任何你想要的颜色添加到js中。在你的小提琴中看不到Jquery代码
$(".add_animation").click(function (){
$("#search").focus().animate({ "background-color": "#B6DADA" }, 800, "linear");
});