frazzlesnazzle Posted July 15, 2011 Share Posted July 15, 2011 I have an FAQ page that contains a series of <div>s which are displayed/hidden based on navigation tabs on the side, and I am trying to install a search functionality using :contain to scan them for keywords but cannot get it working properly. What I have so far is :<script type="text/javascript">function searchFunction() { var searchTerm = document.searchBox.keyword.value;$(".searchable :contains('"+searchTerm+"')").css("style", "display:block");}</script><form name="searchBox">Keyword(s): <input type="text" name="keyword" /><input type="button" value="Search" onclick="searchFunction()"/></form><div class="searchable" id="softwareQuestion1" style="display:none">This is the first software question and answer.</div>What I want is for an input of "software" for example to cause any elements containing that word to be shown.Thanks Link to comment Share on other sites More sharing options...
[dx] Posted July 15, 2011 Share Posted July 15, 2011 How about using achors<a name="first"> something here </a><a name="second"> something else here </a>then faq.php#second will scrool to "something else here"Or you really need to show only one div and hide others? Link to comment Share on other sites More sharing options...
thescientist Posted July 15, 2011 Share Posted July 15, 2011 well, what happens instead? Are you getting any errors? edit:I'm confused why you are using jQuery for everything but getting the value, in which you use old form dot notation. Why not just jquery there as well? var searchTerm = $('#keyword').val();...Keyword(s): <input type="text" name="keyword" id="keyword"/> Link to comment Share on other sites More sharing options...
ShadowMage Posted July 15, 2011 Share Posted July 15, 2011 The syntax for the css() function is wrong. It should look like this:$(".searchable :contains('"+searchTerm+"')").css("display", "block"); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.