jquery模拟SELECT框,效果图如下: 复制代码 代码如下: jquery模拟SELECT框 <BR>body{padding:0;margin:0;font-size:12px;} <BR>ul,li{list-style:none;padding:0;margin:0;} <BR>#dropdown{width:186px; margin:100px auto; position:relative} <BR>.input_select{width:150px; height:24px; line-height:24px; padding-left:4px; padding-right:30px; border:1px solid #a9c9e2; background:#e8f5fe url(arrow.gif) no-repeat rightright 4px; color:#807a62; } <BR>#dropdown ul{width:184px; background:#e8f5fe; margin-top:2px; border:1px solid #a9c9e2; position:absolute; display:none} <BR>#dropdown ul li{height:24px; line-height:24px; text-indent:10px} <BR>#dropdown ul li a{display:block; height:24px; color:#807a62; text-decoration:none} <BR>#dropdown ul li a:hover{background:#c6dbfc; color:#369} <BR>#result{margin-top:10px;text-align:center} <BR> <BR>$(function(){ <BR>$(".input_select").click(function(){ <BR>var ul = $("#dropdown ul"); <BR>if(ul.css("display")=="none"){ <BR>ul.slideDown("fast"); <BR>}else{ <BR>ul.slideUp("fast"); <BR>} <BR>}); <BR>$("#dropdown ul li a").click(function(){ <BR>var txt = $(this).text(); <BR>$(".input_select").val(txt); <BR>var value = $(this).attr("rel"); <BR>$("#dropdown ul").hide(); <BR>$("#result").html("您选择了"+txt+",值为:"+value); <BR>}); <br><br>}); <BR> 北京 上海 武汉 广州