I’m doing some string manipulation to build a jquery selector. Does the trick, but seems a bit ugly to me. Is there a nicer way of doing what I’m doing below?
$(".hierarchical[data-dependson='"+id+"']")
Edit: why does it seem ugly? I’d like to avoid the string manipulation if I can. I’ve seen much nicer looking code using .eq and .has – but I can’t see a way to use them here.
How about this:
Then:
Given a jQuery object collection, this attrIs(attr, value) function will reduce the collection to only those elements with attr == value
Here’s an example: http://jsfiddle.net/RC652/
You could probably modify this method to better suit your own purpose.