记住查询条件cookie

 

<script type="text/javascript">
    ; (function () {
        $.extend($.fn, {
            remberData: function (obj) {
                var _defaultConfig = { key: "", value: "" };
                obj = $.extend(_defaultConfig, obj);
                var $elment = $(this);
                var _cooke = $.cookie(obj.key);
                switch ($(this).prop("nodeName").toLowerCase()) {
                    case "select":
                        if (_cooke) {
                            var _option = $(this).children("option");
                            $.each(_option, function (i,o) {
                                if (o.innerText == _cooke) {
                                    $(o).attr("selected",true);
                                }
                            })
                        }
                        $(this).on("change", function () {
                            $.cookie(obj.key, $(this).children("option:selected").val());
                        })
                        break;
                    case "input":
                        if ($(this).prop("type").toLowerCase() == "text") {
                            if (_cooke) {
                                $(this).val(_cooke);
                            }
                            $(this).on("keyup", function () {
                                $.cookie(obj.key, $(this).val());
                            })
                        }
                        break;
                }
            }
        })
    })();
</script>

 

$("#selectArea").remberData({ key: $("#hidUserID").val() + "_UseSituation_selectArea" });
        $("#txtArea").remberData({ key: $("#hidUserID").val() + "_UseSituation_txtArea" });
        $("#selectBillCount").remberData({ key: $("#hidUserID").val() + "_UseSituation_selectBillCount" });
        $("#txtBillCount").remberData({ key: $("#hidUserID").val() + "_UseSituation_txtBillCount" });

 

posted @ 2016-12-05 15:18  wjl910  阅读(136)  评论(0)    收藏  举报