簡體   English   中英

使用jquery隱藏和顯示div不起作用

[英]hide and show div with jquery not working

我試圖正常隱藏 div 但顯示為用戶單擊下拉列表但不工作 jquery

<div class="form-group">
    <label>Select Course</label>
    <select name="timepass" class="custom-select">
        <option>Select</option>
        <option id="cour">Php Developer</option>
        <option>Asp.Net</option>
        <option>Python</option>
    </select>
</div>
<div class="mj_tabcontent mj_bottompadder80" id="std-list">
    <table class="table table-striped">
        <tr>
            <td>
                <h4><a href="requirement_detail.html">Mudassir Abbas</a></h4>
            </td>
            </td>
            <td>
                <div class="col-xs-2">
                    <input type="text" placeholder="Grade" class="grade">
                </div>
            </td>
        </tr>
            <td>
                <h4><a href="job_detail.html">Ziab u Nisa</a></h4>
            </td>
            <td>
                <div class="col-xs-2">
                    <input type="text" placeholder="Grade" class="grade">
                </div>
            </td>
        </tr>
        </tr>
            <td>
                <h4><a href="job_detail.html">Raja M.Waleed</a></h4>
            </td>
            <td>
                <div class="col-xs-2">
                    <input type="text" placeholder="Grade" class="grade">
                </div>
            </td>
        </tr>
    </table>
</div>

java script code is  
<script>
    $($document).ready(function(){
    $("#std-list").hide();

    $("#cour").click( function(){
    $("#std-list").show();
    });
    });
    </script>

根據我的理解,下面的代碼。 請查收,希望對你有幫助。。

    $(document).ready(function(){
         $('.custom-select').change(function(){
          if($(".custom-select option:selected").index() == 1){
             $('#std-list').show();          
          }else{
             $('#std-list').hide();
          }
         });
    });

 $(document).ready(function(){ $("#hide").click(function(){ $("p").hide(1000); }); $("#show").click(function(){ $("p").show(1000); }); });
 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <p>If you click on the "Hide" button,<br> I will disappear.</p> <button id="hide">Hide</button> <button id="show">Show</button>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM