Home > Article > Web Front-end > jQuery realizes the sliding expansion and hiding effect of controlling pictures by sliding the mouse over the link_jquery
The example in this article describes jQuery’s implementation of sliding the mouse over a link to control the sliding expansion and hiding effects of the image. Share it with everyone for your reference, the details are as follows:
Here is a demonstration of jQuery moving the mouse over a link, sliding to expand/hide the image effect, placing the mouse on the "previous page" and "next page", and the corresponding image will immediately appear, a bit like previewing in advance, allowing users to Knowing the next page or the general content of the next page greatly improves the user experience.
The screenshot of the running effect is as follows:
The online demo address is as follows:
http://demo.jb51.net/js/2015/jquery-mouse-over-link-pic-show-codes/
The specific 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> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>鼠标移动链接上,滑动展开/隐藏图片效果</title> <script language="javascript" src="jquery1.3.2.js"></script> <script type="text/javascript" language="javascript"> $(function(){ $(".list>li:has(div)").hover(function(){ $(this).children('a').addClass('red').end().find('div').slideDown("fast");}, function(){ $(this).children('a').removeClass('red').end().find('div').slideUp("fast"); }); }); </script> <style> *{margin:0;padding:0} body{background:#F8F3ED} li{list-style:none} .list{height:40px;background:#fff;padding-left:100px;} .list li{float:left;position:relative;} .list li a{float:left;width:100px;height:40px;line-height:40px; text-align:center;color:#B7B7B7;text-decoration:none; font-family:"微软雅黑";} .list li a:hover{background:#99C228;color:#FFF;} .list .box{position:absolute;top:40px;left:0;display:none;width:240px;height:170px;background:#99C228;color:#FFF;} .list .box img{width:220px;height:150px;margin:10px;} .list li a:hover,.red{background:#99C228!important;color:#FFF!important;} </style> </head> <body> <ul class="list"> <li><a href="javascript:;">上一页</a> <div class="box"><img src="images/wall_s9.jpg" /></div> </li> <li><a href="javascript:;">下一页</a> <div class="box"><img src="images/wall_s7.jpg" /></div> </li> </ul> </body> </html>
I hope this article will be helpful to everyone in jQuery programming.