2010-07-07 96 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元素,这意味着它的宽度会自动扩展为其父宽度,因此它将覆盖搜索按钮以及登录按钮。