标签 jQuery 下的文章

ajax - 提交 checkbox

html

<button class="batchdel" id="submitbatchdel" type="submit">
    <a href="" onclick="if(confirm('确定要删除数据吗?')) return true;else return false;">批量删除</a>
</button>

阅读全文

jQuery - 回车提交

$(document).keyup(function(e){
    if(e.keyCode == 13){
        $('#submitform').trigger('click');
    }
})
$("#submitform").bind('click', function () {
    var login = {};
    login['username'] = $.trim($("input[name=username]").val());
    login['pwd'] = $.trim($("input[name=pwd]").val());
    login['code'] = $.trim($("input[name=code]").val());
    $('.login-error').html('');
    if (login['username'] == '') {
        errorDis('请输入用户名/手机/邮箱');
        return false;
    }
    if(login['pwd']=='')
    {
        errorDis('请输入密码');
        return false;
    }
    if (login['code'] == '') {
        errorDis('请输入验证码');
        return false;
    }
    $.ajax({
        url: '/login/checkloginmsg',
        type: 'POST',
        dataType: 'json',
        data: login,
        success: function (data) {
        if (data.code == 200) {
            window.location.href = "/main";
        } else {
            errorDis(data.info);//返回错误提示
            return false;
        }
        }
    })
});

阅读全文

jQuery - input 提示

jQuery

<script type="text/javascript">
          $("#username").click(function(event){
              $("#tip-username").show();
              event.stopPropagation();//阻止冒泡
          });
          $("#username").blur(function(){
            $("#tip-username").hide();
          });
          $("body").click(function(){
              $("#tip-username").hide();
          });
          $('#tip-username').click(function(){
              return false;
          });
</script>

阅读全文

jQuery - ajax

jQuery

$.ajax({
            url: '/数据处理页面',
            type: 'POST',
            dataType: 'json',
            data: login,
            success: function (data) {
                if (data.code == 200) {
                    window.location.href = "/验证成功后的跳转页";
                } else {
                    errorDis(data.info);//返回错误提示
                    //alert(data.info);
                    return false;
                }
            }
        })

阅读全文

jQuery - 响应式回顶部按钮

js 代码

$(document).ready(function($){
    // browser window scroll (in pixels) after which the "back to top" link is shown
    var offset = 300,
        //browser window scroll (in pixels) after which the "back to top" link opacity is reduced
        offset_opacity = 800,
        //duration of the top scrolling animation (in ms)
        scroll_top_duration = 700,
        //grab the "back to top" link
        $back_to_top = $('.cd-top');
    //hide or show the "back to top" link
    $(window).scroll(function(){
        ( $(this).scrollTop() > offset ) ? $back_to_top.addClass('cd-is-visible') : $back_to_top.removeClass('cd-is-visible cd-fade-out');
        if( $(this).scrollTop() > offset_opacity ) { 
            $back_to_top.addClass('cd-fade-out');
        }
    });
    //www.sucaijiayuan.com
    //smooth scroll to top
    $back_to_top.on('click', function(event){
        event.preventDefault();
        $('body,html').animate({
            scrollTop: 0 ,
            }, scroll_top_duration
        );
    });
});

阅读全文