저는 자바 스크립트를 처음 사용하며 현재 입력 텍스트 필드에 입력 된 문자열을 하위 문자열로 포함하는 배열의 모든 문자열을 문서에 쓰는 기능을 작성하려고합니다.주어진 하위 문자열을 포함하는 모든 단어 찾기
<!doctype html>
<html lang="en">
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>
<input type="text" >
<p></p>
<script>
var names = ["armadillo", "blue", "com", "demo", "engine"];
$("input").keypress(function() {
var incomplete = $(this).val();
searchStrings();
};
function(searchStrings())
{
for(name in names)
{
if(name.indexOf(incomplete) != -1)
{
document.write(name);
} else
{
document.write("no match found");
}
}
};
});
</script>
</body>
</html>
무엇이 당신 질문입니까? – Mathletics
'function (searchStrings())'이 아마도 문제 일 것입니다. 괄호가 너무 많습니다. 또한 함수에 값을 전달해야합니다. – Mathletics
[jQuery 자동 완성] (http://jqueryui.com/autocomplete/)을 처음부터 개발하려고하십니까? 왜? – h2ooooooo