改变背景色的js代码
2008-07-25 18:39
239 查看
style.backgroundColor以前老弄错 毕竟css样式表里一般写
backgroud-color有点不习惯
另外在表格里的行之间鼠标滑过的时候如果要改变背景色的话 如果单加有点麻烦毕竟要加很多行
css中是可以加js事件的 这样就可以在css中统一定义省去不少麻烦
比如有个简单的table
<table id="t1" >
<tr width="100 px"><td>hello</td></tr>
<tr width="100 px"><td>hello</td></tr>
</talbe>
那么就可以在样式表里面这样写
<style type="text/css">
#t1 tr{
myex:expression(onmouseover=function(){this.style.backgroudColor="#000000";})
}
</style>
#d1{
background-color:#666666;
width:100px;
height:100px;
myex:expression(onmouseover=function(){this.style.backgroundColor="#ff00ff"});
}
这里需要注意的是要加函数不可以直接写表达式
如果写成onmouseover=this.style....则不会出现你想要的效果
如果直接是一个函数的话 就不用加function
比如onmouseover=this.blur;
Type text here
backgroud-color有点不习惯
另外在表格里的行之间鼠标滑过的时候如果要改变背景色的话 如果单加有点麻烦毕竟要加很多行
css中是可以加js事件的 这样就可以在css中统一定义省去不少麻烦
比如有个简单的table
<table id="t1" >
<tr width="100 px"><td>hello</td></tr>
<tr width="100 px"><td>hello</td></tr>
</talbe>
那么就可以在样式表里面这样写
<style type="text/css">
#t1 tr{
myex:expression(onmouseover=function(){this.style.backgroudColor="#000000";})
}
</style>
#d1{
background-color:#666666;
width:100px;
height:100px;
myex:expression(onmouseover=function(){this.style.backgroundColor="#ff00ff"});
}
这里需要注意的是要加函数不可以直接写表达式
如果写成onmouseover=this.style....则不会出现你想要的效果
如果直接是一个函数的话 就不用加function
比如onmouseover=this.blur;
Type text here
相关文章推荐
- CSS 鼠标选中文字后改变背景色的实现代码
- JS原生代码实现鼠标移动图片随之移动效果(另加点击改变图片效果)
- js改变td的背景色
- Css鼠标选中文字后改变背景色的实现代码
- JS点击图片改变图片图径并用正则表达式取图片名的代码
- 使用js改变表格行的背景色
- 用js代码改变单选框选中状态的简单实例
- js改变Lable的innerText后,怎样在后台代码中获得Lable的值
- scrollerView 滚动的时候改变 scrollerView 的背景色代码
- jquery改变tr背景色的示例代码
- 刷新各ifream当前页,下拉项改变触发事件js,给选中项加背景色js
- js改变文章字体大小的实例代码
- 怎么用js代码改变单选框的选中状态
- 改变状态栏文字的js代码
- js控制鼠标移动到表格的某一行时改变该行的背景色
- 在aps.net开发时,改变页面对应的js代码后,重新加载页面后js代码没有加载为最新版本?
- JS 屏蔽按键效果与改变按键效果的示例代码
- 用js代码改变单选框选中状态的简单实例