0
从我的特定问题我已经得到了实现自动完成列表的答案..但问题是当我点击任何建议它空白我的输入框。我有输入框类track
。我的功能,我用于在模糊事件是..组文本框的自动完成列表
<input name="track[]" type="text" class="track" maxlength="150"/>
<div class="suggestionsBox" id="suggestions" style="display: none;">
<img src="images/upArrow.png" style="position: relative; top: -12px; left: 50px;" alt="upArrow" />
<div class="suggestionList" id="autoSuggestionsList"> </div>
</div>
<script>
$('input.track').keyup(function() {
var poetname = $(this).val();
if(poetname.length == 0) {
// Hide the suggestion box.
$(this).parent().find('#suggestions').hide();
}
else {
$.ajax({
url: "rpc.php",
type: "post",
data: {queryString: poetname},
context: this, // i.e. the text box
success: function(data) {
if(data.length >0) {
$(this).parent().find('#suggestions').show();
$(this).parent().find('#autoSuggestionsList').html(data);
}
}
});
}
});
$('input.track').blur(function() {
$(this).val();
$(this).parent().find('.suggestionsBox').hide();
});
</script>
中的代码不能(并且不)做你的描述。请提供更完整的代码示例,其中包括实际更新输入框的部分。 FWIW,你的'$(this).val();'目前什么都不做。 –
我已经编辑了自动列表的关键事件。希望它会有所帮助 –