Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6895283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:53:20+00:00 2026-05-27T06:53:20+00:00

I am designing a simple jquery live search function within a widget on a

  • 0

I am designing a simple jquery live search function within a widget on a site i’m developing. I have borrowed some code I found and it is working great. The problem is though that instead of using a list like this:

  <ul>
    <li>Searchable Item 1</li>
    <li>Searchable Item 2</li>
etc

I am using a list like this:

<ul>
<li>
<a href="#">
<div class="something>
<img src="something.jpg">
<p>Searchable Item 1</p>
</div>
</a>
</li>
etc.

As you can see the text I want to search is in the p tag. The functions I have used are searching all the other stuff (a href, div, img) and matching text found in those tags as well as the item within the p tag. Sorry if my explanation is a bit confusing but I will show you an example of the code here:

//includes im using
<script type="text/javascript" src="js/jquery-1.7.min.js" ></script>
<script type="text/javascript" src="js/quicksilver.js"></script>
<script type="text/javascript" src="js/jquery.livesearch.js"></script>



//document ready function
$(document).ready(function() {
$('#q').liveUpdate('#share_list').fo…
});



//actual search text input field
<input class="textInput" name="q" id="q" type="text" />



//part of the <ul> that is being searched
<ul id="share_list">
<li>
<a href="#">
<div class="element"><img src="images/social/propellercom_icon.jpg… />
<p>propeller</p>
</div>
</a>
</li>


<li>
<a href="#">
<div class="element"><img src="images/social/diggcom_icon.jpg" />
<p>Digg</p>
</div>
</a>
</li>


<li>
<a href="#">
<div class="element"><img src="images/social/delicios_icon.jpg" />
<p>delicious</p>
</div>
</a>
</li>
</ul>

also here is the jquery.livesearch.js file I am using

jQuery.fn.liveUpdate = function(list){
list = jQuery(list);

if ( list.length ) {

var rows = list.children('li'),
cache = rows.map(function(){
return this.innerHTML.toLowerCase();
});


this
.keyup(filter).keyup()
.parents('form').submit(function(){
return false;
});
}

return this;

function filter(){
var term = jQuery.trim( jQuery(this).val().toLowerCase() ), scores = [];

if ( !term ) {
rows.show();
} else {
rows.hide();

cache.each(function(i){
var score = this.score(term);
if (score > 0) { scores.push([score, i]); }
});

jQuery.each(scores.sort(function(a, b){return b[0] - a[0];}), function(){
jQuery(rows[ this[1] ]).show();
});
}
}
};

I believe the problem lies here:

var rows = list.children('li'),
cache = rows.map(function(){
return this.innerHTML.toLowerCase();
});

it is just using whatever it finds between the li tags as the search term to compare against the string entered into the text input field. The search function actually does work but seems to find too many matches and is not specific as I am also using a quicksilver.js search function that matches terms that are similar according to a score. When I delete all the other stuff from the li list (a href, img, div, etc) the search function works perfectly. If anyone has any solution to this I would be really greatful, I have tried things like:

return this.children(‘p’).innerHTML but it doesn’t work, I’m ok with PHP, C++, C# etc but totally useless with javascript and Jquery, they’re like foreign languages to me!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:53:21+00:00Added an answer on May 27, 2026 at 6:53 am

    In the jquery.livesearch.js file I believe you can replace this line:

    var rows = list.children('li'),
    

    with:

    var rows = list.children('li').find('p'),
    

    This should make it so the livesearch plugin will only search the paragraph tags in your list.

    You will need to change the .show()/.hide() lines to reflect that you are trying to show the parent <li> elements since you are now selecting the child <p> elements:

    Change:

    rows.show();//1
    rows.hide();//2
    jQuery(rows[ this[1] ]).show();//3
    

    To:

    rows.parents('li:first').show();//1
    rows.parents('li:first').hide();//2
    jQuery(rows[ this[1] ]).parents('li').show();//3
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm designing a fairly simple web site but as I don't have much experience
I'm designing a simple web-app in CI. I have a registration controller, and a
I am designing a simple model in Django(1.3) which has 3 fields and some
I just finished designing a simple code program. I called it a Guessing Game.
I am designing a website utilizing CI and jquery. I have today been working
Im designing a simple dealership site that involves several features. Users can sign on
I'm currently designing a simple forum application. It's mostly powered by jQuery/AJAX and loads
I'm designing a simple web app for some elderly family members, 1 of whom
I am looking for some help on designing a simple pivot so that I
I'm having a simple GUI environment with a button widget (a jQuery plugin). There's

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.