2010-07-07 69 views
0

好吧,所以我有一個登錄按鈕在我的網站的頂部,當點擊calles一些jquery顯示/隱藏登錄框。jquery幫助切換

但我有一個搜索框旁邊,當你點擊,不僅無法輸入它,但它也切換日誌在框中的第一個代碼應該是jquery和secong是html部分這叫它。順便說一句,它的jQuery 1.4.2。如果你想看到它,你可以訪問http://www.stat-me.com並點擊登錄,並嘗試單擊搜索博

謝謝。

JQUERY:

<script src="js/jquery/jquery-1.4.2.js" type="text/javascript"></script> 
<script language="javascript" type="text/javascript"> 
// run the function below once the DOM(Document Object Model) is ready 
$(document).ready(function() { 
    // trigger the function when clicking on an assigned element 
    $(".toggle").click(function() { 
     // check the visibility of the next element in the DOM 
     if ($(this).next().is(":hidden")) { 
      $(this).next().slideDown(); // slide it down 
     } else { 
      $(this).next().slideUp("fastS"); // hide it 
     } 
    }); 

$(".exito").click(function() { 
     // check the visibility of the next element in the DOM 
     if ($(this).next().is(":hidden")) { 
      $(this).next().show(); // slide it down 
     } else { 
      $(this).next().hide(); // hide it 
     } 
    }); 
}); 
</script> 

HTML:

<span class="toggle" style="margin-top:-583px; margin-left:950px; position:relative;"> 

<a href="#">LOG IN</a> 

</span> 


<div class="secondehiddendiv"> 
<div class="chat-bubble"> 
    <h1 style="color:#F00">LOG IN!</h1> 
<form name="login" method="post" action="login.php"> 
    <table style="margin-left:-5px; text-align:right; color:#F00;"> 
    <tr> 
    <td>Email:</td> 
     <td><input name="email" type="text" size="17" ></td> 
    </tr> 
    <tr> 
    <td>Password:</td> 
     <td><input name="password" type="password" size="17" ></td> 
    </tr> 
    </table> 

    <div class="log_in_img"> 
    <input type="image" src="http://www.stat-me.com/images/log_in_jq.png" alt="LOG IN" > 
    </div> 
</form> 

    <div class="chat-bubble-arrow-border"></div> 
    <div class="chat-bubble-arrow"></div> 

</div> 
</div> 

回答

1

你撥動跨度在搜索框的前部延伸:


您可以通過添加的50像素的寬度到您的切換修復它(像你一樣),或者更好(帕特里克建議)添加在相關數據表:

<td> 
    <span class="toggle"> 
    <a href="#">LOG IN</a> 
    </span> 
</td> 
+0

讓我怎麼停止(IM還挺新) – DonJuma 2010-07-07 15:01:01

+0

沒關係我得到它我只是說50分像素的感謝的寬度很多 – DonJuma 2010-07-07 15:06:10

+0

在帕特里克建議的搜索框中添加您的登錄鏈接。我用一個例子編輯了我的答案。 – stormdrain 2010-07-07 15:10:27

1

.toggle跨度位於頁面底部,並定位在頂部/右使用大量的利潤。

爲什麼採取這種方法?爲什麼不把它放在要單擊的元素的同一張表中?

它不起作用的原因是,您將span設置爲顯示爲block元素,這意味着它的寬度會自動擴展爲其父寬度,因此它將覆蓋搜索按鈕以及登錄按鈕。