- 让下拉框中显示图片,并可选择对应图片,让select下拉框不仅可显示文字,还可以显示图片内容。为了更生动些,这里还加入了jQuery动画效果,当展开Select列表的时候,图片渐变显示。使用了一个jQ插件:imageselect.js,使用效果的朋友可以自己下载吧。
<!DOCTYPE html> <head> <title>支持图片选择的jQuery列表框插件imageselect.js</title> <script type="text/javascript" src="/ajaxjs/jquery-1.6.2.min.js" ></script> <script type="text/javascript" src="/jscss/demoimg/201312/imageselect.js"></script> <style> .jqis{position: relative;} .jqis_header{background-image: url('/jscss/demoimg/201312/dropdown_arrow.png');background-position: right center;background-repeat: no-repeat;cursor: pointer;} .jqis_header img{cursor: pointer;} .jqis_dropdown{padding: 5px;position: absolute;overflow-x: hidden;overflow-y: scroll;} .jqis_dropdown img{margin-right: 3px;cursor: pointer;float: left;} </style> </head> <body> <p>潜水式无堵塞排污泵</p>
<select name="logo">
<option value="1">/jscss/demoimg/wall_s5.jpg</option> <option value="2">/jscss/demoimg/wall_s8.jpg</option> <option value="3">/jscss/demoimg/wall_s7.jpg</option> <option value="4">/jscss/demoimg/wall_s6.jpg</option> </select> <script type="text/javascript"> $(document).ready(function(){ $('select[name=logo]').ImageSelect({dropdownWidth:425}); }); </script> </body> </html>