2015-09-14 165 views
-2
$('#TOTSBILT').click(function(){ 
    $("#Vsauceisgenius").show("slow"); 
    $(".arrow-left").show("slow"); 
}); 

爲什麼它沒有顯示DIV我也有這個代碼jQuery的顯示和隱藏

$("#CTSO").click(function(){ 
     $("#Vsauceisgenius").hide("slow"); 
     $(".arrow-left").hide("slow"); 

沒有錯誤

<div id="TOTSBILT" ><img src="../img/lupa.png" ID="ILDSIB" class="OKSD"></div><div id="ATSIMD"><div class="arrow-left" id="JUHBG"></div><div id="Vsauceisgenius" > 
    <img src="../img/x.png" id="CTSO" href="#"><form method="post" action="ppl.php" > 
    <input type="text" name="username" placeholder="People" id="IMOHD"><input type="submit" name="Searc" value="Search" id="DPMM"> 
    </form><P></P> 
    <form method="get"> 
    <input type="text" placeholder="Hashtags" id="IMOHDS"><input type="submit" value="Search" id="DPMMM"></form> 
</div> 
</div><h1 ID="jcss">2</H1> 
+1

是你的id唯一嗎?如果不是,請使其唯一。可能是動態創建嗎?如果是使用事件委託 – guradio

+0

@皮卡它是唯一的 –

+0

它是動態創建的嗎? – guradio

回答

1

試試這個:

$(function(){ 
 
$("#CTSO").click(function() { 
 
    $("#Vsauceisgenius").hide("slow"); 
 
    $(".arrow-left").hide("slow"); 
 
});//close this click handler 
 
$('#TOTSBILT').click(function() { 
 
    $("#Vsauceisgenius").show("slow"); 
 
    $(".arrow-left").show("slow"); 
 
}); 
 
    });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div id="TOTSBILT" ><img src="http://www.clker.com/cliparts/Q/l/L/B/F/a/search-icon-hi.png" style="width:20px;height:20px;" ID="ILDSIB" class="OKSD"></div><div id="ATSIMD"><div class="arrow-left" id="JUHBG"></div><div id="Vsauceisgenius" > 
 
    <img src="https://cdn3.iconfinder.com/data/icons/softwaredemo/PNG/256x256/DeleteRed.png" id="CTSO" href="#" style="width:20px;height:20px;"><form method="post" action="ppl.php" > 
 
    <input type="text" name="username" placeholder="People" id="IMOHD"><input type="submit" name="Searc" value="Search" id="DPMM"> 
 
    </form><P></P> 
 
    <form method="get"> 
 
    <input type="text" placeholder="Hashtags" id="IMOHDS"><input type="submit" value="Search" id="DPMMM"></form> 
 
</div> 
 
</div><h1 ID="jcss">2</H1>

+0

沒有它不工作 –

+0

@J。 doe什麼是不工作?,運行代碼段並檢查,它正在工作,只需更換你的代碼和try.see在控制檯中的任何錯誤。 –

+0

噢,它是工作,我忘了jquery謝謝 –