1

コンテンツ編集可能な div があり、文字を入力すると、キャレット位置の近くに自動提案を表示しようとしています。


私はこのようなものを探しています..しかし、以下のコードは機能していません

        var editor  = document.getElementById('myDiv');
        var t=$(editor).offset().top;
        var l=$(editor).offset().left;
        var caretPosition = getCaretPosition(editor);
        var autoSuggestionDiv = document.getElementById('divResult');
        autoSuggestionDiv.style.top = t + caretPosition + "px";
        autoSuggestionDiv.style.left = l + caretPosition + 20 + "px";
        var inputSearch = getCharacterPrecedingCaret(editor);
        var dataString = 'searchword='+ inputSearch;
        if(inputSearch!='')
        {
            $.ajax({
            type: "POST",
            url: "Search.aspx",
            data: dataString,
            cache: false,
            success: function(html)
            {
            $("#divResult").html(html).show();
            }
            });
        }
4

0 に答える 0