Say I have 4 div elements with class .navlink, which, when clicked, use .data() to set a key called \'selected\', to a value of
.navlink
.data()
\'selected\'
your filter would work, but you need to return true on matching objects in the function passed to the filter for it to grab them.
var $previous = $('.navlink').filter(function() { return $(this).data("selected") == true });