I have a content-editable div and I am trying to show an auto-suggestion near to my caret positon when i type a character.
i am looking for something like this.. but the below code is not working
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();
}
});
}