innerHTML修改内容,内容是修改了~但是显示不出来!
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html>
<head>
<title> 0_o </title>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<style type= "text/css ">
div{width:98px;height:98px;border:1px solid black;float:left;cursor:pointer;background:red;}
</style>
<script language= "javascript ">
function getvalue()
{
this.innerHTML= "a ";
alert(this.innerHTML);
}
</script>
</head>
<body>
<div id= "ba " onclick= "getvalue() "> xxxxxxxx </div>
</body>
</html>
内容是修改了~但是显示不出来!但是不能把JS写在onclick属性里面哦!该怎么处理呢??
------解决方案-------------------- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html>
<head>
<title> 0_o </title>
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 " />
<style type= "text/css ">
div{width:98px;height:98px;border:1px solid black;float:left;cursor:pointer;background:red;}
</style>
<script language= "javascript ">
function getvalue(obj)
{
obj.innerHTML= "a ";
alert(obj.innerHTML);
}
</script>
</head>
<body>
<div id= "ba " onclick= "getvalue(this) "> xxxxxxxx </div>
</body>
</html>
------解决方案-------------------- <div id= "ba " onclick= "getvalue() "> xxxxxxxx </div>
这样触发getvalue函数里面的this不是指向这个div