手记

javascript--列表页搜索 js实现 选中上一次搜索的条件

<script type="text/javascript">

    $("input .focus").focus();

    var searchlist = location.search.substring(1);

    if (search) {

        try {

            var querylist = JSON.parse('{"' + decodeURIComponent(searchlist).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}');

            $.each(querylist, function(k, v) {

                $('[name=' + k + ']').val(v);

            });

        } catch (e) {

            console.log(e);

        }

    }

</script>


0人推荐
随时随地看视频
慕课网APP