bɪˈ*_*ɪnə 5 html javascript css jquery
这里的代码重点放在第二个div上.现在我想将聚焦元素的背景颜色设置为另一种颜色几秒钟,然后淡化回原始颜色.怎么做?
$(function(){
$("#two").focus();
});Run Code Online (Sandbox Code Playgroud)
body{color:white;}
#fis{height:600px;width: 60px;background-color:red;}
#two{height:600px;width: 60px;background-color:green;}
#thr{height:600px;width: 60px;background-color:blue;}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="fis">hello
</div>
<div id='two' tabindex='1'>mr
</div>
<div id='thr'>john
</div>Run Code Online (Sandbox Code Playgroud)
按照以下方式,您可以在一段时间内改变颜色。首先它会变黄,几秒钟后又变回绿色。
$(function(){
$("#two").focus();
setTimeout(function() {
$('#two').css("background-color", "green");
}, 2000);
});Run Code Online (Sandbox Code Playgroud)
body{color:white;}
#fis{height:600px;width: 60px;background-color:red;}
#two{height:600px;width: 60px;background-color:yellow; transition:background-color 1s ease;}
#thr{height:600px;width: 60px;background-color:blue;}Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="fis">hello
</div>
<div id='two' tabindex='1'>mr
</div>
<div id='thr'>john
</div>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
834 次 |
| 最近记录: |