像上面的一张图片我们该怎么用js 和css + div 很好的应用到我们的项目中呢?
<style>
.InpuRight{
height:20px;background:url(img/msg_bg.png) no-repeat;background-position:0px -250px;
}
.InputError{
width:20px;height:20px;background:url(img/msg_bg.png) no-repeat 0px 0px;
}
.inputLogin{
width:20px;height:20px;background:url(img/msg_bg.png) no-repeat;background-position:0px -150px;
}
</style>
定义的css样式,仔细看InputError和其它的区别你会明白很多
看看页面是怎么定义的呢:
<div id="ceshi" class="inputLogin"></div>
<a href="javascript:checkName()" >click</a>
再看看我们的js吧
function checkName(){
var uu = document.getElementById("ceshi");
uu.className="InpuRight";
uu.innerHTML=" <font color='red'>asdfdsf</font>";
}
看看我们的一开始运行吧
再看看click后的吧
小小的研究啊,用去了我半天的时间,悔恨当初没有好好的学啊!