zoukankan      html  css  js  c++  java
  • js dairy

    //留言js逻辑
    $(document).ready(
            function() {
                $("#post_btn").click(
                        function() {
                            var comment = $('#comment').val();
                            // 检查是否登录
                            window.lib.checkLoginState(1);
                            // 数据判断
                            if ($.trim(comment) == "") {
                                window.lib.myAlert("留言不能为空!", 1000);
                                $('#comment').focus();
                                return;
                            }
                            // 提交数据
                            $.ajax({
                                type : "post",
                                url : contextPath + "/message/add",
                                dataType : "json",
                                data : {
                                    message : "" + comment
                                },
                                success : function(json) {
                                    if (json["status"] == "success") {
                                        $('div.commt_list div:eq(0)').prepend(
                                                $('<dl><dt>你的留言</dt><dd>' + comment
                                                        + '</dd></dl>'));
                                        window.lib.myAlert('提交成功!', 500);
                                    } else {
                                        window.lib.myAlert('提交失败!', 500);
                                    }
                                }
                            });
                        });
    
                /* initiate plugin assigning the desired button labels */
                $("div.holder").jPages({
                    containerID : "itemContainer",
                    first : "第一页",
                    previous : "上一页",
                    next : "下一页",
                    last : "最后一页",
                    perPage : 5
                });
            });
    
    // 控制输入字数
    $(document).ready(function() {
        var limitNum = 500;
        var pattern = '还可以输入' + limitNum + '字';
        $('#post_tips').html(pattern);
        $('#comment').keyup(function() {
            var remain = $(this).val().length;
            if (remain > limitNum) {
                pattern = "字数超过限制!";
            } else {
                var result = limitNum - remain;
                pattern = '还可以输入' + result + '字';
            }
            $('#post_tips').html(pattern);
        });
    });
    
    ;
    (function(context) {
        context.lib = window.lib || {};
        myAlert = function(info, timeout) {
            $.blockUI({
                message : info,
                css : {
                    border : 'none',
                    padding : '15px',
                    backgroundColor : '#000',
                    '-webkit-border-radius' : '10px',
                    '-moz-border-radius' : '10px',
                    opacity : .5,
                    color : '#fff'
                }
            });
            setTimeout($.unblockUI, timeout);
        };
        context.lib.myAlert = myAlert;
    })(this);
      
  • 相关阅读:
    iOS 实现多个按钮,点选一个其它都取消选中状态的最佳方法
    iOS隐藏导航条1px的底部横线
    ios url 编码和解码
    ClassLoader
    Java多线程
    Tomcat8-启动脚本分析
    Cmd
    java命令
    Http报文
    断点续传原理
  • 原文地址:https://www.cnblogs.com/muyoushui/p/3329343.html
Copyright © 2011-2022 走看看