{"id":8059,"date":"2015-11-09T16:15:39","date_gmt":"2015-11-09T14:15:39","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=8059"},"modified":"2017-12-21T15:46:50","modified_gmt":"2017-12-21T13:46:50","slug":"jquery-filter-example","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/","title":{"rendered":"jQuery Filter Example"},"content":{"rendered":"<p>The aim of this example is to have a look at the <code>.fiter();<\/code> method of jQuery. What this method does is reduce the set of matched elements to those that match the selector or pass the function&#8217;s test. <\/p>\n<p>In other words, the filter() method returns elements that match a certain criteria. It lets you specify a criteria. Elements that do not match the criteria are removed from the selection, and those that match will be returned. This method is often used to narrow down the search for an element in a group of selected elements.<\/p>\n<p>If you are already familiar with the <code>.not()<\/code> method, then you probably understand this is the opposite method.<br \/>\n[ulp id=&#8217;qGGDqWnle19VavkM&#8217;]<\/p>\n<h2>1. Document Setup<\/h2>\n<p>To begin, create a new HTML document and add the following basic syntax inside:<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n\t&lt;title&gt;jQuery Filter Example&lt;\/title&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\r\n&lt;!-- HTML SECTION  --&gt;\r\n\r\n\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n&lt;script src=\"jquery-1.11.3.min.js\"&gt;&lt;\/script&gt;\r\n\r\n&lt;script type=\"text\/javascript\"&gt;\r\n\r\n&lt;\/script&gt;\r\n\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n<\/pre>\n<p>Notice that the jQuery library is linked locally. To download it, please go <a href=\"https:\/\/jquery.com\/download\/\" target=\"_blank\">here<\/a>.<\/p>\n<h3><strong>Syntax<\/strong><\/h3>\n<p>The basic syntax of this method is: <code>$(selector).filter(criteria,function(index));<\/code><\/p>\n<p>Criteria is optional. It specifies a selector expression, a jQuery object or one or more elements to be returned from a group of selected elements. Adding a function is also optional. It specifies a function to run for each element in the set. If it returns true, the element is kept. Otherwise, the element is removed.<\/p>\n<h2>2. Basic Application<\/h2>\n<p>Let&#8217;s now see the method applied in an example. First add some paragraph elements. Those will be the ones from which some will be filtered.<\/p>\n<pre class=\"brush:xml\">\r\n&lt;!-- HTML SECTION  --&gt;\r\n&lt;h3&gt;Look at the filtered elements:&lt;\/h3&gt;\r\n&lt;p&gt;They call me Jack, like the drink.&lt;\/p&gt;\r\n&lt;p class=\"one\"&gt;I live in the Jungle, with the tigers.&lt;\/p&gt;\r\n&lt;p class=\"one\"&gt;No one ever visits a mamooth by default.&lt;\/p&gt;\r\n&lt;p&gt;Paragraphs are meant to be understood, not just read.&lt;\/p&gt;\r\n<\/pre>\n<p>In the JS section, after selecting the <code>p<\/code> element, we apply the <code>filter()<\/code> method to it and specify a class as an argument to the method, the <code>\".one\"<\/code> class. These will then be the two elements on which several css properties are going to be added.<\/p>\n<pre class=\"brush:js\">\r\n&lt;!-- JAVASCRIPT SECTION  --&gt;\r\n&lt;script type=\"text\/javascript\"&gt;\r\n$(document).ready(function(){\r\n    $(\"p\").filter(\".one\").css({\r\n        \"text-transform\": \"uppercase\",\r\n        \"font-weight\": \"bold\",\r\n        \"color\": \"red\"\r\n    });\r\n});\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>Notice the red, bold and uppercase text. Those are the elements filtered and styled.<br \/>\n<figure id=\"attachment_8070\" aria-describedby=\"caption-attachment-8070\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-1.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-1.jpg\" alt=\"A basic application of the filter method.\" width=\"820\" height=\"241\" class=\"size-full wp-image-8070\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-1.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-1-300x88.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-8070\" class=\"wp-caption-text\">A basic application of the filter method.<\/figcaption><\/figure><\/p>\n<h2>3. Cases and Exmaples<\/h2>\n<p>In addition to the basic application, there are quite a few other examples of how the method can be used.<\/p>\n<h3>3.1 Using Pseudo Selectors<\/h3>\n<p>Not only can you filter classes, but also use pseudo selectors to capture certain elements. Look at the example below:<\/p>\n<pre class=\"brush:xml\">\r\n&lt;ul&gt;\r\n    &lt;li&gt;Even List Item&lt;\/li&gt;\r\n    &lt;li&gt;Odd List Item&lt;\/li&gt;\r\n    &lt;li&gt;Even List Item&lt;\/li&gt;\r\n    &lt;li&gt;Odd List Item&lt;\/li&gt;\r\n    &lt;li&gt;Even List Item&lt;\/li&gt;\r\n    &lt;li&gt;Odd List Item&lt;\/li&gt;\r\n&lt;\/ul&gt;\r\n<\/pre>\n<p>As you can see, above we have an unordered list with six list items. And you can see the text corresponds to their even\/odd relation. Notice that in programming languages counting actually begins with 0 and not 1. That might be confusing, but it is a standard rule on every programming language.<\/p>\n<p>Now in the JS section, instead of entering a class as an argument to the filter method, we enter a pseudo-selector like this: <code>.filter(\":pseudo\")<\/code><\/p>\n<pre class=\"brush:js\">\r\n&lt;script type=\"text\/javascript\"&gt;\r\n$(document).ready(function(){\r\n    $(\"li\").filter(\":odd\").css({\r\n        \"background-color\": \"yellow\",\r\n        \"width\": \"20%\",\r\n        \"font-weight\": \"bold\"\r\n    });\r\n});\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>The result would be:<br \/>\n<figure id=\"attachment_8073\" aria-describedby=\"caption-attachment-8073\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-2.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-2.jpg\" alt=\"Using Pseudo Selectors as Arguments\" width=\"820\" height=\"179\" class=\"size-full wp-image-8073\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-2.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-2-300x65.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-8073\" class=\"wp-caption-text\">Using Pseudo Selectors as Arguments<\/figcaption><\/figure><\/p>\n<h3>3.2 Using Multiple Criteria<\/h3>\n<p>What if you wanted more than one filter applied? Well, you can just enter as many filters you want by separating with a comma. Let&#8217;s see an example:<\/p>\n<pre class=\"brush:xml\">\r\n&lt;div&gt;\r\n    &lt;h4 class=\"one\"&gt;Class One Here&lt;\/h4&gt;\r\n    &lt;h4 id=\"two\"&gt;Class Two Here&lt;\/h4&gt;\r\n    &lt;h4 class=\"three\"&gt;Class Three Here&lt;\/h4&gt;\r\n    &lt;h4 class=\"four\"&gt;Class Four Here&lt;\/h4&gt;\r\n    &lt;h4 id=\"five\"&gt;Class Five Here&lt;\/h4&gt;\r\n    &lt;h4 class=\"six\"&gt;Class Six Here&lt;\/h4&gt;\r\n&lt;div&gt;\r\n<\/pre>\n<p>Here we added six <code>h4<\/code> elements and gave all of them either a class or an id, in a random definition. Below, we&#8217;ll only be filtering elements with a class of <code>\".three\"<\/code> and an id of <code>\"#five\"<\/code> like so:<\/p>\n<pre class=\"brush:js\">\r\n&lt;script type=\"text\/javascript\"&gt;\r\n$(document).ready(function(){\r\n    $(\"h4\").filter(\".three, #five\").css({\r\n        \"background-color\": \"#c0392b\",\r\n        \"padding\": \"1em\",\r\n        \"color\": \"white\",\r\n        \"width\": \"20%\"\r\n    });\r\n});\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>The result in the browser would be:<br \/>\n<figure id=\"attachment_8078\" aria-describedby=\"caption-attachment-8078\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-3.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-3.jpg\" alt=\"Using Multiple Criteria\" width=\"820\" height=\"325\" class=\"size-full wp-image-8078\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-3.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-3-300x119.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-8078\" class=\"wp-caption-text\">Using Multiple Criteria<\/figcaption><\/figure><\/p>\n<h3>3.3 Using a Function as an Argument<\/h3>\n<p>Specifying a function inside the <code>.filter()<\/code> method surely gives you a lot more power in aspects of what you can achieve filtering elements. Below we&#8217;ll have a look at a simple example where we use a function to select all elements in which the division by 3 would give us a remainder of 1. First add some list items:<\/p>\n<pre class=\"brush:xml\">\r\n&lt;ul&gt;\r\n    &lt;li&gt;First List Item&lt;\/li&gt;\r\n    &lt;li&gt;Second List Item&lt;\/li&gt;\r\n    &lt;li&gt;Third List Item&lt;\/li&gt;\r\n    &lt;li&gt;Fourth List Item&lt;\/li&gt;\r\n    &lt;li&gt;Fifth List Item&lt;\/li&gt;\r\n    &lt;li&gt;Sixth List Item&lt;\/li&gt;\r\n&lt;\/ul&gt;\r\n<\/pre>\n<p>Next, specify the function inside the method and give it an <code>index<\/code> as the function parameter. After that, just <code>return index % 3 == 1<\/code>.<\/p>\n<pre class=\"brush:js\">\r\n&lt;script type=\"text\/javascript\"&gt;\r\n$(document).ready(function(){\r\n    $( \"li\" ).filter(function( index ) {\r\n        return index % 3 === 1;\r\n      }).css( \"background-color\", \"yellow\" );\r\n});\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>The only li items for which the condition is true are the second (index = 1) and fifth (index = 4).<br \/>\n<figure id=\"attachment_8085\" aria-describedby=\"caption-attachment-8085\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-4.jpg\"><img decoding=\"async\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-4.jpg\" alt=\"Using a Function as the Method Argument\" width=\"820\" height=\"193\" class=\"size-full wp-image-8085\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-4.jpg 820w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/filter-4-300x71.jpg 300w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-8085\" class=\"wp-caption-text\">Using a Function as the Method Argument<\/figcaption><\/figure><\/p>\n<h2>4. Conclusion<\/h2>\n<p>To conclude, the <code>.filter()<\/code> method enables an easy way to select and manipulate any DOM elements we need, by providing flexibility in adding multiple classes\/id&#8217;s, using functions, pseudo-selectors etc.<\/p>\n<p>It is useful in many cases when you want to differentiate elements from the whole scope and apply methods to them, in order to create a distinct view or behaviour for those particular elements.<\/p>\n<h2>5. Download<\/h2>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2015\/10\/jQuery-Filter.zip\"><strong>jQuery Filter<\/strong><\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The aim of this example is to have a look at the .fiter(); method of jQuery. What this method does is reduce the set of matched elements to those that match the selector or pass the function&#8217;s test. In other words, the filter() method returns elements that match a certain criteria. It lets you specify &hellip;<\/p>\n","protected":false},"author":75,"featured_media":919,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-8059","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jquery"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>jQuery Filter Example - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"The aim of this example is to have a look at the .fiter(); method of jQuery. What this method does is reduce the set of matched elements to those that\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"jQuery Filter Example - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"The aim of this example is to have a look at the .fiter(); method of jQuery. What this method does is reduce the set of matched elements to those that\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/fabiocimo\" \/>\n<meta property=\"article:published_time\" content=\"2015-11-09T14:15:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-12-21T13:46:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Fabio Cimo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@fabiocimo\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Fabio Cimo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/\"},\"author\":{\"name\":\"Fabio Cimo\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22\"},\"headline\":\"jQuery Filter Example\",\"datePublished\":\"2015-11-09T14:15:39+00:00\",\"dateModified\":\"2017-12-21T13:46:50+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/\"},\"wordCount\":726,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"articleSection\":[\"jQuery\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/\",\"name\":\"jQuery Filter Example - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"datePublished\":\"2015-11-09T14:15:39+00:00\",\"dateModified\":\"2017-12-21T13:46:50+00:00\",\"description\":\"The aim of this example is to have a look at the .fiter(); method of jQuery. What this method does is reduce the set of matched elements to those that\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"jQuery\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/jquery\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"jQuery Filter Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22\",\"name\":\"Fabio Cimo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g\",\"caption\":\"Fabio Cimo\"},\"description\":\"Fabio is a passionate student in web tehnologies including front-end (HTML\/CSS) and web design. He likes exploring as much as possible about the world wide web and how it can be more productive for us all. Currently he studies Computer Engineering, at the same time he works as a freelancer on both web programming and graphic design.\",\"sameAs\":[\"https:\/\/www.facebook.com\/fabiocimo\",\"https:\/\/al.linkedin.com\/in\/fabiocimo\",\"https:\/\/x.com\/fabiocimo\",\"https:\/\/www.youtube.com\/fabiocimo1\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/fabio-cimo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"jQuery Filter Example - Web Code Geeks - 2026","description":"The aim of this example is to have a look at the .fiter(); method of jQuery. What this method does is reduce the set of matched elements to those that","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/","og_locale":"en_US","og_type":"article","og_title":"jQuery Filter Example - Web Code Geeks - 2026","og_description":"The aim of this example is to have a look at the .fiter(); method of jQuery. What this method does is reduce the set of matched elements to those that","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_author":"https:\/\/www.facebook.com\/fabiocimo","article_published_time":"2015-11-09T14:15:39+00:00","article_modified_time":"2017-12-21T13:46:50+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","type":"image\/jpeg"}],"author":"Fabio Cimo","twitter_card":"summary_large_image","twitter_creator":"@fabiocimo","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Fabio Cimo","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/"},"author":{"name":"Fabio Cimo","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22"},"headline":"jQuery Filter Example","datePublished":"2015-11-09T14:15:39+00:00","dateModified":"2017-12-21T13:46:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/"},"wordCount":726,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","articleSection":["jQuery"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/","name":"jQuery Filter Example - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","datePublished":"2015-11-09T14:15:39+00:00","dateModified":"2017-12-21T13:46:50+00:00","description":"The aim of this example is to have a look at the .fiter(); method of jQuery. What this method does is reduce the set of matched elements to those that","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jquery-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/jquery\/jquery-filter-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"jQuery","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/jquery\/"},{"@type":"ListItem","position":4,"name":"jQuery Filter Example"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/1dfb88b4a8d08c37a6080311fd330a22","name":"Fabio Cimo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b3df055f2e1b62e238889fafbb16121c68aab1adcd11af670e185cafae201b3b?s=96&d=mm&r=g","caption":"Fabio Cimo"},"description":"Fabio is a passionate student in web tehnologies including front-end (HTML\/CSS) and web design. He likes exploring as much as possible about the world wide web and how it can be more productive for us all. Currently he studies Computer Engineering, at the same time he works as a freelancer on both web programming and graphic design.","sameAs":["https:\/\/www.facebook.com\/fabiocimo","https:\/\/al.linkedin.com\/in\/fabiocimo","https:\/\/x.com\/fabiocimo","https:\/\/www.youtube.com\/fabiocimo1"],"url":"https:\/\/www.webcodegeeks.com\/author\/fabio-cimo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/8059","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/75"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=8059"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/8059\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/919"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=8059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=8059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=8059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}