JS动态图片的实现方法完整示例
qq_42412646 人气:0本文实例讲述了JS动态图片的实现方法。分享给大家供大家参考,具体如下:
<html> <head> <meta charset="UTF-8"> <title>js-是动态实现图片显示</title> <script type="text/javascript"> // 设置图片的动态效果 function photoOper(ph,photo){ // 获取图片对象 // var ph=document.getElementById(id); //可以通过id获得,但是没必要,我们可以直接使用this直接把对象传过来 ph.style.border="solid 1px"; //我们是重新赋值,所以我们要用=赋值符,而不是:各个是属性说明 // 在大屏块显示 big.src=photo; //传过来的数据就已经是一个字符串类型了,虽然我们src的值需要是字符串,但是如果再加一个""就会导致路径不明,这样其实际图片名相当于带了"" } //src是big的属性的是不是样式属性,可以直接调用修改,不用加style function photoOper2(ph){ ph.style.border=""; //移出后边框值没 } </script> <style type="text/css"> #showdiv{ width: 500px; height: 440px; border: solid 1px; border-radius: 15px; } #ta{ margin: auto; margin-top: 10px; margin-left: 10x; } img{ margin-left: 3px; } </style> </head> <body> <div id="showdiv"> <table id="ta"> <tr> <td colspan="4" width="490px" height="344px"><img src="http:/https://img.qb5200.com/download-x/demo.jb51.net/js/2018/html5-css3-3d-img-flash-codes/images/Guardians-of-the-Galaxy-Poster-High-Res.jpg" width="490px" id="big"/></td> </tr> <tr> <td height="68px"><img src="http:/https://img.qb5200.com/download-x/demo.jb51.net/js/2018/html5-css3-3d-img-flash-codes/images/Blade-Runner-poster-art-Harrison-Ford.jpg" height="65px" id="p1" onmousemove="photoOper(this,'http:/https://img.qb5200.com/download-x/demo.jb51.net/js/2018/html5-css3-3d-img-flash-codes/images/Blade-Runner-poster-art-Harrison-Ford.jpg')" onmouseout="photoOper2(this)"/></td> <td><img src="http:/https://img.qb5200.com/download-x/demo.jb51.net/js/2018/html5-css3-3d-img-flash-codes/images/2017_alien_covenant_4k-5120x2880-1920x1080.jpg" height="65px" onmousemove="photoOper(this,'http:/https://img.qb5200.com/download-x/demo.jb51.net/js/2018/html5-css3-3d-img-flash-codes/images/2017_alien_covenant_4k-5120x2880-1920x1080.jpg')" onmouseout="photoOper2(this)" /></td> <td><img src="http:/https://img.qb5200.com/download-x/demo.jb51.net/js/2018/html5-css3-3d-img-flash-codes/images/robocop-1987-wallpaper-2.jpg" height="65px" onmousemove="photoOper(this,'http:/https://img.qb5200.com/download-x/demo.jb51.net/js/2018/html5-css3-3d-img-flash-codes/images/robocop-1987-wallpaper-2.jpg')" onmouseout="photoOper2(this)"/></td> <td><img src="http:/https://img.qb5200.com/download-x/demo.jb51.net/js/2018/html5-css3-3d-img-flash-codes/images/sJALsDXak4EehSg2F2y92rt5hPe.jpg" height="65px" onmousemove="photoOper(this,'http:/https://img.qb5200.com/download-x/demo.jb51.net/js/2018/html5-css3-3d-img-flash-codes/images/sJALsDXak4EehSg2F2y92rt5hPe.jpg')" onmouseout="photoOper2(this)"/></td> </tr> </table> </div> </body> </html>
运行效果:
希望本文所述对大家JavaScript程序设计有所帮助。
加载全部内容