当鼠标移到按钮上时,按钮的背景色改变为另一种颜色。当鼠标移开后,按钮背景色又变回原来的颜色。
5 个解决方案
#1
<input type="button" text="click me" onmouseover="this.runtimeStyle.backgroundColor=red" onmouseout="this.runtimeStyle.backgroundColor=''">
#2
我是问在CSS文件中该怎么写??
#3
我是问在CSS文件中该怎么写??
>>寫不了
>>寫不了
#4
好象用htc能实现啊!有谁用过?
#5
下面是用HTC实现的:
htc 文件内容:
/////////////////////////
/// file name : c.htm
////////////////////////
<public:component>
<public:attach event="onmouseover" onevent="m_over()" />
<public:attach event="onmouseout" onevent="m_out()" />
<script language="jscript">
function m_over()
{
element.runtimeStyle.backgroundColor = "yellow";
}
function m_out()
{
element.runtimeStyle.backgroundColor = "";
}
</script>
</public:component>
下面是个 html 文件的内容:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<style type="text/css">
.b
{
behavior:url(c.htc);
}
</style>
</HEAD>
<BODY>
<input type="button" value="click me" class="b">
</BODY>
</HTML>
把两个文件保存在同一个目录下面。
htc 文件内容:
/////////////////////////
/// file name : c.htm
////////////////////////
<public:component>
<public:attach event="onmouseover" onevent="m_over()" />
<public:attach event="onmouseout" onevent="m_out()" />
<script language="jscript">
function m_over()
{
element.runtimeStyle.backgroundColor = "yellow";
}
function m_out()
{
element.runtimeStyle.backgroundColor = "";
}
</script>
</public:component>
下面是个 html 文件的内容:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<style type="text/css">
.b
{
behavior:url(c.htc);
}
</style>
</HEAD>
<BODY>
<input type="button" value="click me" class="b">
</BODY>
</HTML>
把两个文件保存在同一个目录下面。
#1
<input type="button" text="click me" onmouseover="this.runtimeStyle.backgroundColor=red" onmouseout="this.runtimeStyle.backgroundColor=''">
#2
我是问在CSS文件中该怎么写??
#3
我是问在CSS文件中该怎么写??
>>寫不了
>>寫不了
#4
好象用htc能实现啊!有谁用过?
#5
下面是用HTC实现的:
htc 文件内容:
/////////////////////////
/// file name : c.htm
////////////////////////
<public:component>
<public:attach event="onmouseover" onevent="m_over()" />
<public:attach event="onmouseout" onevent="m_out()" />
<script language="jscript">
function m_over()
{
element.runtimeStyle.backgroundColor = "yellow";
}
function m_out()
{
element.runtimeStyle.backgroundColor = "";
}
</script>
</public:component>
下面是个 html 文件的内容:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<style type="text/css">
.b
{
behavior:url(c.htc);
}
</style>
</HEAD>
<BODY>
<input type="button" value="click me" class="b">
</BODY>
</HTML>
把两个文件保存在同一个目录下面。
htc 文件内容:
/////////////////////////
/// file name : c.htm
////////////////////////
<public:component>
<public:attach event="onmouseover" onevent="m_over()" />
<public:attach event="onmouseout" onevent="m_out()" />
<script language="jscript">
function m_over()
{
element.runtimeStyle.backgroundColor = "yellow";
}
function m_out()
{
element.runtimeStyle.backgroundColor = "";
}
</script>
</public:component>
下面是个 html 文件的内容:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<style type="text/css">
.b
{
behavior:url(c.htc);
}
</style>
</HEAD>
<BODY>
<input type="button" value="click me" class="b">
</BODY>
</HTML>
把两个文件保存在同一个目录下面。