给元素自定义属性赋值
例如,消除页面上的链接虚线框。 通常的做法是:
〈a href=“link1.htm“ onfocus=“this.blur()“〉link1〈/a〉
〈a href=“link2.htm“ onfocus=“this.blur()“〉link2〈/a〉
〈a href=“link3.htm“ onfocus=“this.blur()“〉link3〈/a〉
粗看或许还体现不出采用expression的优势,但如果你的页面上有几十甚至上百个链接,这时的你难道还会机械式地Ctrl+C,Ctrl+V么,何况两者一比较,哪个产生的冗余代码更多呢?
采用expression的做法如下:
〈style type=“text/css“〉
a {star : expression(onfocus=this.blur)}
页码:[1] [2] [3] [4] [5] [6] 第3页、共6页 |