以下是我实施的示例。我希望当用户提供输入时它应该与结果匹配,并且应该在键入后选择。这可以用HTML或jQuery或Javascript实现吗?提前谢谢。
var list = document.getElementById("list"); // Get the target element
var parent = list.parentNode; // Get its parent
var newList = generateListFromArray(array); // Get the new one
parent.insertBefore(
newList, // Insert the new list...
list // ...before the old one
);
parent.removeChild(list); // Remove the old
newList.id = "list"; // Give the new list the ID the
// old one had