今天做了一个下拉框的友情连接,跟select操作有点不一样,记录下,代码如下:
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>测试</title> <link type="text/css" rel="stylesheet" href="http://static.xitongcheng.cc/css/sty.css"> <script type="text/javascript" src="jquery.min.js"></script> </head> <body> <select class="form_select" name="view_dropdownlist_55_843"> <option selected>苏老的学习笔记</option> <option value="https://sulao.cn/category-1.html">php笔记</option> <option value="https://sulao.cn/category-2.html">mysql笔记</option> <option value="https://sulao.cn/category-3.html">mssql笔记</option> <option value="https://sulao.cn/category-4.html">linux笔记</option> </select> <script type="text/javascript"> $(function(){ $(".form_select").click(function(){ var index = $(".form_select").get(0).selectedIndex; //获取索引 var jumpurl = $(".form_select").find("option:selected").val(); if(index != 0 && jumpurl){ window.open(jumpurl); $(".form_select option").attr("selected",false); } }); }); </script> </body> </html>