时间: 2021-07-31 作者:daque
题目证明: 用过css款式咱们就领会, 不妨设置一批东西的class属性来指定同一个款式来一致界面. 但怎样一致同典型的东西的事变? 比方:界面有多数个 <img src="http://www.okasp.com/techinfo/**.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"> 请将鼠标放在a.jpg上看看功效