JQuery Mobile Div在页面访问时加载

时间:2015-10-18 07:59:12

标签: javascript jquery html css jquery-mobile

请新手Jquery / Javascript和Jquery Mobile。我有两页,第一页和第二页。在第二页,我把一个div隐藏起来,只显示点击一个按钮的时间。但是,只要从第一页点击第二页的链接,div就会自动加载,但在刷新时div会正常运行。

我的HTML

<div class="content">
    <div class="dont_show center b">Please Wait...<br /><img src="images/loading.gif" /></div>
    <div class="b">
        <div>
            <img height="10%" width="10%" src="images/logo.png" alt="" />
        </div>
        <div class="inner-addon left-addon">
            <i class="glyphicon glyphicon-user"></i>      
            <input type="email" data-clear-btn="true" class="form-control" id="email" required="required" placeholder="Email Address" />
        </div>
        <div><a href="#" onclick="forgot(); return false;" class="btn btn-primary">Reset Password</a></div>
    </div>
</div>

我的css

 #dont_show, .dont_show { display: none; } 

Jquery的

function forgot(){
    $('.b').toggle();
    var email = $('#email').val();
    if(email == '') {
        alert('Email Is Required');
        $('.b').toggle();
        return;
    }
}

1 个答案:

答案 0 :(得分:0)

使用以下代码 HTML

<div class="content">
    <div class="dont_show center b">Please Wait...<br /><img src="images/loading.gif" /></div>
    <div class="b">
    <div>
        <img height="10%" width="10%" src="images/logo.png" alt="" />
    </div>
    <div class="inner-addon left-addon">
        <i class="glyphicon glyphicon-user"></i>      
        <input type="email" data-clear-btn="true" class="form-control" id="email" required="required" placeholder="Email Address" />
    </div>
    <div><a href="#" class="btn btn-primary">Reset Password</a></div>
</div>

的JavaScript

$(document).ready(function(){
$('a').click(function(){
$('.b').toggle();
var email = $('#email').val();
if(email == '') {
    alert('Email Is Required');
    $('.b').toggle();
    return;
}
});
 });

CSS

#dont_show, .dont_show { display: none; }