0

入力テキストボックスで機能しないJqueryオートコンプリート

以下は私のJavaScriptコードです

 <script type="text/javascript" src="js/jquery.js"></script>
 <script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
 <script type="text/javascript" src="js/jquery.jcarousel.min.js"></script>
 <script type="text/javascript" src="js/jquery.cycle.all.min.js"></script>
 <script type="text/javascript" src="js/serverSideValidation.js"></script>
 <script type="text/javascript" src="js/clientSideValidation.js"></script>
 <script type="text/javascript" src="js/jquery.ui.autocomplete.min.js"></script>

 <script type="text/javascript">

 $(document).ready(
function() {
    $('#slideshow').cycle({
        fx : 'fade',
        speed : 'slow',
        timeout : 5000,
        pager : '#slider_nav',
        pagerAnchorBuilder : function(idx, slide) {
            // return sel string for existing anchor
            return '#slider_nav li:eq(' + (idx) + ') a';
        }
    });

    addSearchHelp();
});

function addSearchHelp() {
    var availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC",
            "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang",
            "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp",
            "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme" ];
    $("input#searchBox")[0].autocomplete({source:availableTags, minLength: 2});
}

以下は私の入力テキストボックスです

<input name="searchBox" id="searchBox" type="text" class="input-header" 
style="background-image:url(images/search-bg.png); background-repeat:repeat-x; 
background-position:center; height:31px; width:423px" size="65" maxlength="60" 
 onblur="this.value=Trim(this.value)" onkeypress="return checkenter(event,'product')" 
  />

私の問題に対する答えを提案してください

4

2 に答える 2

2

こうやってみて、

脚本

    $(document).ready(function() {
        $('#slideshow').cycle({
            fx : 'fade',
            speed : 'slow',
            timeout : 5000,
            pager : '#slider_nav',
            pagerAnchorBuilder : function(idx, slide) {
                // return sel string for existing anchor
                return '#slider_nav li:eq(' + (idx) + ') a';
            }
        });

        $('#searchBox').on('keyup', function(event){
            addSearchHelp();
        });

    });

    function addSearchHelp() {
        var availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC",
                "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang",
                "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp",
                "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme" ];
        $("input#searchBox").autocomplete({source:availableTags, minLength: 2});
    }

HTML

<input name="searchBox" id="searchBox" type="text" class="input-header" size="65" maxlength="60" onblur="this.value=Trim(this.value)" onkeypress="return checkenter(event,'product')" />

これがあなたを助けることを願っています。

于 2013-05-06T12:12:27.807 に答える