javascript淡出但不淡入

时间:2013-09-20 13:18:50

标签: javascript jquery asp.net vb.net

我有以下代码:

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
 <script  type="text/javascript">
        function goToSignup() {
            $("#register").fadeIn("fast");
            $("#login").fadeOut("fast");
        }
        function goToLogin() {
            $("#login").fadeIn("fast");
            $("#register").fadeOut("fast");
        }                        
    </script>

这是我的asp代码:

   <div id="login" class="animate form">

       <h1>Log in</h1> 
      <p> 
          <label for="username" class="uname" data-icon="u" > Your username </label>
          <asp:Textbox runat="server" id="username"  name="username" type="text" placeholder="myusername"/>
     </p>
     <p> 
     <label for="password" class="youpasswd" data-icon="p"> Your password </label>
     <asp:Textbox runat="server" id="password"  name="password" type="password" placeholder="eg. X8df!90EO" /> 
     </p>
     <p class="keeplogin"> 
<input type="checkbox" name="loginkeeping" id="loginkeeping" value="loginkeeping" /> 
<label for="loginkeeping">Keep me logged in</label>
   </p>

   </div>

   <div id="register" class="animate form" >
    <h1> Sign up </h1> 
     <p> 
       <label for="usernamesignup" class="uname" data-icon="u">Firstname</label>
      <label for="usernamesignup" class="uname"  style="color: red;">*</label>
         <asp:CustomValidator ID="CustomValidator2" runat="server" Display="Dynamic"
        ValidationGroup="registerGRP" Font-Bold="true" ForeColor="Red" onservervalidate="cusCustom_RegisterValidate"></asp:CustomValidator>
      <asp:Textbox runat="server" id="Firstname" name="usernamesignup" type="text" placeholder="mysuperusername690" />
        </p>
      <p> 
     <label for="usernamesignup" class="uname" data-icon="u">Lastname</label>
     <label for="usernamesignup" class="uname"  style="color: red;">*</label>
      <asp:Textbox runat="server" id="Lastname" name="usernamesignup" type="text" placeholder="mysuperusername690" />
      </p>
       <p> 
       </div>

这是我的vb.net代码:

    Protected Sub btn_login_Click(sender As Object, e As System.EventArgs) Handles btn_login.Click
    If Session("valid") Then
        ScriptManager.RegisterStartupScript(Me.Page, Me.[GetType](), "foo", "goToLogin()", True)
    End If
End Sub

Protected Sub btn_signup_Click(sender As Object, e As System.EventArgs) Handles btn_signup.Click
    'Dim tbUserName As TextBox = Page.FindControl("username")
    'tbUserName.required = False
    ScriptManager.RegisterStartupScript(Me.Page, Me.[GetType](), "foo", "goToSignup()", True)
End Sub

当我点击按钮时,div淡出,但当我检查我的页面时,另一个div不会淡入我获取容器,但它在页面中是不可见的

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

检查你的CSS中是否设置了

visibility:hidden;

对于您的某个面板。 正在努力工作

display:none;

这里有一个解决方法:

   function goToSignup() {
        $('#register').css('visibility','visible').hide().fadeIn('fast');            
        $("#login").fadeOut("fast");
    }
    function goToLogin() {
        $('#login').css('visibility','visible').hide().fadeIn('fast');            
        $("#register").fadeOut("fast");
    }