笑故挽风 2015-03-04 08:44 采纳率: 100%
浏览 16

jQuery不起作用

I have write this cause to show and hide select component with jQuery, but it doesn't function, can you tell me where is the problem?

<html>
<head>
<meta charset='UTF-8' />
    <script  type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Exo:100,200,400">
    <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:700,400,300">
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>

Here is CSS part to display.hide

<style type="text/css">
    .hide {
       display: none;
    }                  
</style>

The jQuery code

<script>
$(document).ready(function () {
    function changeType() {
            if ($("#typeservice").val() == "voice") {
                $("#country").show();
                $("#sgnl").show();
                $("#Operator").hide();
                $("#tech").hide();
            }
            if ($("#typeservice").val() == "data") {
                $("#country").show();
                $("#sgnl").hide();
                $("#Operator").show();
                $("#tech").hide();
            }
            if ($("#typeservice").val() == "Radio") {
                $("#country").show();
                $("#sgnl").hide();
                $("#Operator").hide();
                $("#tech").show();
            }
    }
});
</script>   
</head>
<body> 
    <select id="typeservice" style="width: 100px" onchange="changeType();">
    </select>

    <select id="sgnl" style="width: 100px; ">
    </select>

    <select  id="country" style="width: 100px;">
    </select>
</body>
</html>

But all the select component appears and no display or dynamic show!

  • 写回答

2条回答 默认 最新

  • weixin_33670713 2015-03-04 09:03
    关注

    In document ready function hide all select component other than typeservice dropdown. Try the following code to hide components in document ready.

    $(document).ready(function(){
        $("#country").hide();
        $("#sgnl").hide();
        $("#Operator").hide();
        $("#tech").hide();
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试