zoukankan      html  css  js  c++  java
  • select的option触发事件

    <!DOCTYPE html>
    <html lang="zh">
    
        <head>
            <meta charset="UTF-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1.0" />
            <meta http-equiv="X-UA-Compatible" content="ie=edge" />
            <title>Document</title>
            <style type="text/css">
                .option_show {
                    display: none;
                }
                
                .discount {
                    width: 70px;
                }
            </style>
        </head>
    
        <body>
            <select class="select" name="oyhfd">
                <option value="0" selected="selected">请选择</option>
                <option class="option" value="1">足球</option>
                <option class="option" value="2">篮球</option>
                <option class="option" value="3">乒乓球</option>
                <option class="option" value="4">网球</option>
            </select>
            <span style="display:none;" class="option_show">
        <input type="text" class="discount" id="" name="" placeholder="其他球类"/>
      </span>
        </body>
    
        <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
        <script>
            $(".select").on("change", function() {
                if($("option:selected", this).val() == 4) {
                    $(".option_show").show();
                } else {
                    $(".discount").val("");
                    $(".option_show").hide();
                }
            });
        </script>
    
    </html>
     
  • 相关阅读:
    linux系统用户登陆时脚本执行顺序
    stm32 win7 64位虚拟串口驱动安装失败解决办法
    python全栈day6
    python全栈day5
    江湖救急(处理域名未备案网站问题)
    python全栈day4
    python全栈day3
    python全栈day2
    python全栈day1
    PHP 跨域之header
  • 原文地址:https://www.cnblogs.com/zbly/p/9969078.html
Copyright © 2011-2022 走看看