javascript input改变css的样式使用的语法如下:document.getElementById(id).style.property=new style例如:Hello World! document.getElementById("p2").style.color="blue"; 备注:JS改变元素属性的方法如下: var div = document.getElementByIdx_x('d1'); div.setAttribute("class", "abc");...
javascript input改变css的样式
javascript是吧,绑个事件
如:<input type='text' id='abc' onfocus='getfocus()' onblur='lostfocus()' />
js代码:
function getfocus(){
document.getElementById("abc").className = "input_one_bg";
}
function lostfocus{
document.getElementById("abc").className = "input_bg";
}
jQuery简单一点
$(document).ready(function(){
$("#abc").focus(function(){
$(this).Class("input_one_bg");
})
$("#abc").blur(function(){
$(this).Class("input_bg");
})
})
之前的class名搞错了,已对调2013-06-06
$("input").focus(function(){ $("input").css("background-image","路径");});$("input").blur(function(){ $("input").css("background-image","路径");});2013-06-06
javascript input改变css的样式使用的语法如下:
document.getElementById(id).style.property=new style例如:
<p id="p2">Hello World!</p> <script> document.getElementById("p2").style.color="blue"; </script>备注:JS改变元素属性的方法如下:
<script> var div = document.getElementByIdx_x('d1'); div.setAttribute("class", "abc"); </script>2015-07-11
给它一个聚焦和离焦的事件,聚焦的时候,使用.input_bg 样式,blur时,使用.input_one_bg样式2013-06-06
Vue实践-CSS样式position/display/float属性对比使用
2020-12-25