jquery - How to search/filter by image source? -


i'm trying make page can filter source name of image.

i found script it's working on text: http://kilianvalkhof.com/2010/javascript/how-to-build-a-fast-simple-list-filter-with-jquery/

fiddle: jsfi ddle.net/svjrk/

what need filter image source? see: jsfi ddle.net/svjrk/1/

any advice great!

in answer question asked in title, attribute contains selector you're looking for:

$('img[src*="sport"]')

which select images, src property contains sport.


as question specifically, there number of issues:

  1. you're passing $('#list') listfilter function, don't have element id.
  2. you're calling $(list) within function body, you've passed list jquery object, there's no need wrap again.
  3. you're looking anchors contain given string, don't have anchors within list (you have images).
  4. there's no need custom :contains selector if need check if string contained within src of image (you can use attribute contains selector).

here's working fiddle above changes


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -