根据<select>选项隐藏div

时间:2017-11-10 15:40:45

标签: javascript jquery html select dropdown

我有一个带有选择下拉列表(显示网络列表),密码字段和提交按钮的表单。 它将下拉列表配置为在受密码保护的网络上显示挂锁,否则显示无密码图像。这很好用。 我想要实现的是隐藏密码字段div,如果用户从下拉列表中选择打开(无需密码)网络,但我无法使其工作。 表格:  &lt; form id =“network”&gt;  &lt; select class =&#34; select1 long&#34; ID =&#34;苍白-SSID&#34;名称=&#34;苍白-SSID&#34; &GT;&LT; /选择&GT; &lt; div id =“showhidepassword”&gt;  &lt; input id =&#34; wan-key&#34;类型=&#34;文本&#34;占位符=&#34;留空以保留 不变&#34;名称=&#34;苍白密钥&#34;&GT;&LT; / DIV&GT; &lt; div class =&#34; div_submit&#34;&gt; &lt;输入类型=&#34;提交&#34; ID =&#34; submit_wan&#34;类=&#34; button_submit&#34;值=&#34; &LT;%提交%GT;&#34;&GT; &lt; div id =&#34; wan-message&#34;类=&#34; ERRORMSG&#34;&GT;&LT; / DIV&GT; &LT; /形式&GT; 脚本(带有e的图像是挂锁图像):     ... 站= sortByKey(result.stations,&#34;质量&#34);         for(var i = 0; i&lt; stations.length; i ++){             var img;             var has_password = true;             if(stations [i] .Encryption ==&#34; none&#34;)has_password = false;             if(stations [i] .Quality == 100)img =(has_password?&#34; /images/100e.png":&#34; /images/100.png");             否则if(stations [i] .Quality&gt; = 50)img =(has_password?&#34; /images/75e.png":&#34; /images/75.png");             否则if(stations [i] .Quality&gt; = 25)img =(has_password?&#34; /images/50e.png":&#34; / images/50.png");             else img =(has_password?&#34; /images/25e.png":&#34; /images/25.png");             var has_password = false;             if(stations [i] .Encryption ==&#34; none&#34;);             $(“#showhidepassword”)隐藏()。             else $(“#showhidepassword”)。show();

0 个答案:

没有答案
相关问题