Reuse Your Element Searches

Submitted by:Jhon Smith

Date added:24 April, 2012


Example shown here how to Reuse Your Element Searches

Tags: reuse element

Code Snippet:

var allItems = $("div.item");
var keepList = $("div#container1 div.item");
//Now you can keep working with those jQuery objects. For example,
//trim down the "keep list" based on checkboxes whose names
//correspond to
<div>class names:
$(formToLookAt + " input:checked").each(function() { keepList = keepList.filter("." + $(this).attr("name")); });</div>