日期:2014-05-16  浏览次数:20368 次

Jquery动态添加的li实现键盘控制li
这是动态添加li
 //当键盘输入和焦点移动
        function down(str) {
            var reg = /^(\w|[\u4E00-\u9FA5])*$/;
            //判断是否为中文、字母、数字
            if (str.match(reg)) {
                $.ajax({
                    type: 'GET',
                    url: 'http://smartbox.gtimg.cn/s3/?r=' + Math.random() + '&q=' + str + '&t=all',
                    dataType: 'script',
                    success: function (data) {
                        if (str == "") {
                            $("#Div").addClass('none');
                        } else {
                            ch = new Array;
                            ch = v_hint.split("^");
                            $("li").remove();
                            //判断返回的字符串是否为空
                            if (ch != "N") {
                                $("#Div").removeClass('none block');
                                $("#Div").addClass('block');
                                $("#container").addClass('block');
                              
                                var old&nb