Skip to content

Instantly share code, notes, and snippets.

@dedg3
Created January 10, 2013 14:22
Show Gist options
  • Save dedg3/4502356 to your computer and use it in GitHub Desktop.
Save dedg3/4502356 to your computer and use it in GitHub Desktop.
Filter Objects by data attribute value
/*
<div id="proto_1" data-state="open">Div 1 - proto open</div>
<div id="">Div 2</div>
<div id="proto_3" data-state="closed">Div 3 - proto closed</div>
<div id="proto_4" data-state="open">Div 4 - proto open</div>
*/
var $el = $('div[id^=proto_]').filter('div[data-state=open]').css('color','red');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment