Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

Super Fast / Efficient jQuery Live Search

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
1,577
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Dec 6, 2011

This is a DOM live search on some data you already have on the page. This does NOT go back to some server or database. The TRICK here is to use the jQuery attributes contains selector

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (optikalefxx)

  • this is retarded. you should be searching a values in a javascript array.

  • @kriogenx0 Although your comment was kind of asshole-like. You have a good point. But I would have to have unique IDs on all the elements, and store those in the array so they can be immediately targeted.

  • @optikalefxx Why would you need unique ids? It'd be best to parse all the DOM elements into an array of objects, or array of values. Then search that. You would cache that array for future searches as well, in case the user changes that search.

  • @kriogenx0 Sure you could cache each of the DOM elements in the array, but that means you still have to loop through the UL at least once to get each DOM object. Which is still probably faster.

  • Isn't it bad practice to use custom attributes on HTML tags?

  • @limited06 kinda, its against the spec. If you like you can just add data- infront and then your valid html5 again

see all

All Comments (17)

Sign In or Sign Up now to post a comment!
  • Cool. How about highlighting what you typed within the search result text?

  • yeah, it will be good if you don't have to support the "SHITTY" browsers like "FIREFOX" or ie.

    in the end, it is such an easy task that i don't think older IEs can't handle with speeds. Not to mention Firefox.

  • Another extremely valuable tutorial Sean. Thanks for sharing it with the rest of us.

  • @RTStaniforth thanks

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more