Using CSS expression to realize batch control of interface objects

Source: Internet
Author: User
Tags define expression interface
css|express| Object | Control problem Description: Using CSS styles We know that you can define the class attribute of a batch of objects to specify the same style to unify the interface. But how do you unify events of the same type of objects? For example: The interface has countless <img src= "http://edu.cnzz.cn/newsinfo/**.jpg" > How to implement the mouse through this picture, the picture of Src become **_over.jpg?


 


 


Workaround: Use CSS expression method,


specific implementation to see. The writing of CSS:


 


/* Replace picture css*/


#imgScript {/* Here you use object IDs to match styles, or you can define a CSS function */


Star:expression (


onmouseover = function ()


    {


/* Replacement picture */


if (this.hover!= null) {


this.name = this.src;


this.src = This.src.replace ('. jpg ', ' _over.jpg ');


This. HASCHG = 1;


       }


   },


onmouseout = function ()


  { 


/* Restore the original picture * *


if (this. HASCHG!= null) {


this.src = this.name;


this. HASCHG = null;


    }


 }


)

}/*end imgscript*/

Application-style IMG:


Please put the mouse on the a.jpg to see the effect







Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.