<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>产品</title> <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1"> <meta name="renderer" content="webkit"> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/> <script type="text/javascript" src="js/glo_view.js"></script> <link rel="stylesheet" type="text/css" href="css/reset.css"/> <link rel="stylesheet" type="text/css" href="css/flex.css"/> <link rel="stylesheet" type="text/css" href="css/swiper.min.css"/> <script type="text/javascript" src="js/jquery-1.10.2_d88366fd.js"></script> <script type="text/javascript" defer src="js/swiper-3.3.1.min.js"></script> <link rel="stylesheet" type="text/css" href="css/shijian.css"/> <script type="text/javascript" defer src="js/jquer_shijian.js"></script> <link rel="stylesheet" type="text/css" href="css/LArea.css"/> <script type="text/javascript" defer src="js/LArea.js"></script> <link rel="stylesheet" type="text/css" href="css/publicMethods.css"/> <script type="text/javascript" defer src="js/publicMethods.js"></script> <link rel="stylesheet" type="text/css" href="css/xt_wap.css"/> <script type="text/javascript" defer src="js/xt_wap.js"></script> </head> <body> <div class="width750center"> <!--header--> <div class="xtw_header"> <div class="xtw_header_fix"> <div class="xtw_header_fix_back xtw_header_fix_backfn all-flex all-justify-start all-align-items-center"> <img src="images/topleft.png" > </div> <div class="xtw_header_fix_txt">添加联系人</div> <div class="xtw_header_fix_right all-flex all-justify-end all-align-items-center"> <!--<img src="images/topleft.png" >--> </div> </div> </div> <!--cont--> <div class=""> <script> /* * jq对象,要显示那些元素[],要隐藏那些元素[] */ function toggleOptionShow(obj,arrShow,arrHide){ function arrHandle(arr,type){ if($.isArray(arr)){ var len=arr.length; for(i=0;i<len;i++){ var optionNow=obj.find("option").eq(arr[i]); var optionP=optionNow.parent("span"); if(type=="show"){ if(optionP.size()){ optionP.children().clone().replaceAll(optionP); } }else{ if(!optionP.size()){ optionNow.wrap("<span style=‘display:none‘></span>"); } } } } } arrHandle(arrShow,"show"); arrHandle(arrHide,"hide"); } </script> <select> <option value="papername" selected="selected">选项一</option> <option value="state">选项二</option> <option value="state">选项三</option> <option value="state">选项四</option> <option value="state">选项五</option> <option value="state">选项六</option> </select> <button onclick="toggleOptionShow($(‘select‘),‘‘,[0,1,3])">隐藏一,二,四</button> <button onclick="toggleOptionShow($(‘select‘),[0,1,3],‘‘)">显示一,二,四</button> </div> </div> </body> <script> $(function () { }) </script> </html>
原文地址:https://blog.csdn.net/sanyuedexuanlv/article/details/26455925