|
css里expression实现界面对象的批量控制
来源:
互联网
日期:2006-5-11
用过css样式我们就知道, 可以定义一批对象的class属性来指定同一个样式来统一界面. 但如何统一同类型的对象的事件? 比如:界面有无数个 <img src="**.jpg"> 如何实现鼠标经过此图片, 图片的src变成是**_over.jpg? 解决方法: 使用css的expression方法,具体实现要看看.css的写法:
/*替换图片CSS*/ #imgScript { /*这里使用对象ID来通配样式, 也可以定义一个css函数*/ star:expression( onmouseover = function() { /*替换图片*/ if(this.hover != null){ this.name = this.src; this.src = this.src.replace('.jpg', '_over.jpg'); this.HasChg = 1; } }, onmouseout = function() { /*还原本来的图片*/ if(this.HasChg != null){ this.src = this.name; this.HasChg = null; } } ) }/*end imgScript*/ |
应用样式的img:
<img src="a.jpg">
更多的css里expression实现界面对象的批量控制请到论坛查看: http://BBS.TC711.COM
【 双击滚屏 】 【 评论 】 【 收藏 】 【 打印 】 【 关闭 】
来源:
互联网
日期: 2006-5-11
|
|
|
|
| 精品推荐 |
|
 |
| 本月推荐 |
|
 |
| 友情赞助 |
|
|
|