Filters the elements in the Gimme Object's internal array based on the given filter function, filterFn.

Returns: Itself (the newly filtered Gimme Object is returned so additional methods can be chained together seamlessly).
  • filterFn, required: A reference to a function that returns eithers true or false. The function should return true if the element is to remain in the Gimme Object's array, false if it is to be removed.

// Puts a solid red border around all <div> elements whose .innerHTML contains the text "SAVE ME"
g('div').filter(f1).setStyle('border', '5px solid red');
function f1(el)
	return el.innerHTML.indexOf('SAVE ME') !== -1;

// Hides all <p> elements whose opacity is less than .5
g('p').filter(f2).setStyle('display', 'none');
function f2(el)
	return g(el).getStyle('opacity') < .5;

Last edited Jul 9, 2007 at 5:48 PM by sstchur, version 1


No comments yet.