With jQuery, it is easy to select elements with a given attribute value.
For example:
var elements = $(\'div[attr1=\"value1\"]\');
You could for example chain and filter like so
var elements = $('div[attr1="value1"]').filter('div[attr2="value2"]');