I’m trying to search through the p tag content inside the .list and I’m probably just over complicating this but my alert isn’t working, maybe it’s because of other code I have on the page this isn’t functioning but I was wondering if someone can help me figure out where I’m going wrong.
JS
$(document).ready(function() {
var sresults = $('.mainsearch input').val();
var sfinder = $('.list p').find(sresults).text(sresults);
$('.mainsearch input').keyup(function () {
$('.search-help').append(sfinder);
alert(sfinder);
});
});
HTML
<div class="mainsearch">
<input/>
<div class="search-help">Results:
</div>
</div>
<div class="list">
<span><p>test</p></span>
<span><p>another result</p></span>
<span><p>yet another result</p></span>
</div>
something like this?
http://jsfiddle.net/h7uYB/
Update:
try this:
http://jsfiddle.net/h7uYB/2/