Post Implementation Method:
Code
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> No title page </title>
<Script src = "jquery-1.3.2.js" type = "text/javascript"> </script>
<Style type = "text/css">
. Rootclass {border: none; position: relative ;}
</Style>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ (". Rootclass"). mousemove (function (e ){
Var positionX = e. originalEvent. x | e. originalEvent. layerX | 0;
If (positionX <= $ (this). width ()/2 ){
This. style. cursor = 'url ("pre. cur"), auto ';
$ (This). attr ('title', 'click to view the previous file ');
$ (This). parent (). attr ('href ', $ (this). attr ('left '));
} Else {
This. style. cursor = 'url ("next. cur"), auto ';
$ (This). attr ('title', 'click to view the next one ');
$ (This). parent (). attr ('href ', $ (this). attr ('right '));
}
});
});
</Script>
</Head>
<Body>
<A href = "#">
</A>
</Body>
</Html>
Note: 1. Jquery needs to be called.
2. Here we use a speculative method to obtain the mouse position in the image and set the position of the image: relative
Use var positionX = e. originalEvent. x | e. originalEvent. layerX | 0; to obtain the value.
3. Add left = "http://www.google.cn" right = "http://www.baidu.cn" for the previous, next link address on the image for convenience. Remember to set <a href = "#"> </a>
DEMO code: http://demo.jb51.net/js/img_left_right/jquery_img_lr.htm
Packaging http://www.jb51.net/jiaoben/25129.html
Related Articles:
ClientX, pageX, offsetX, x, layerX, screenX, offsetLef
Differences between common functions of JS in IE and FireFox
Differences between javascript offsetX and layerX
JQuery click the image to jump to the previous or next function implementation code