私のFAQページに検索機能を追加しようとしています。contains()を使用してdivコンテンツを表示/非表示にするページ内検索
私が欲しいのは、ユーザーがキーワードを入力し、そのキーワードに対してjqueryを実行し、関連するすべての回答のdisplay:blockを設定するテキストボックスです。
私はこれまででてきた何:
<form name="searchBox">
Keyword(s): <input type="text" name="keyword" />
<input type="button" value="Search" onClick="searchFunction()" />
</form>
<div class="searchable" style="display:none">
This is the first software question and answer.</div>
<div class="searchable" style="display:none">
This is the first hardware question and answer.</div>
<script type="text/javascript">
function searchFunction() {
var searchTerm = document.searchBox.keyword.value;
$(" :contains('"+searchTerm+"')").addStyle("display:block"); }
</script>
「searchTerm」の値は何ですか? –
これがなぜ機能していないのかを詳しく教えてください。 –