javascript 控制css js控制 clss
像上面的一张图片我们该怎么用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后的吧
小小的研究啊,用去了我半天的时间,悔恨当初没有好好的学啊!
相关文档:
this是Javascript语言的一个关键字。
它代表函数运行时,自动生成的一个内部对象,只能在函数内部使用。比如,
function test(){
this.x = 1;
}
随着函数使用场合的不同,this的值会发生变化。但是有一个总的原则,那就是this指的是,调用函数的那个对象。
下面分四种情况,详细讨论this的用法。
......
JavaScript操作服务器控件之Gridview控件
1.JavaScript脚本如下:
<script language="javascript" type="text/javascript">
function gridviewControl()
{
//获取GridView的客户端元素
  ......
s<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档< ......
<html>
<head>
<title>changePage</title>
</head>
<body>
<table id="pic" cellpadding="0" cellspacing="0" border="1" width="200" height="100" bordercolor="red">
<tr>
<td>picture chanage!</td>
</tr>
</table>
< ......