I have a jQuery object representing a DIV:
$rel = $('#rel_'+rel.id);
In that DIV, there is a BUTTON with my custom attribute "rid" set to rel.id
I need to select that button, it works like this:
$("[rid='"+rel.id+"']").html();
But I think that's not the fastest possible solution as it needs to parse the whole DOM for that and because I know the button is always inside the DIV, I could avoid that.
I tried it with the following code:
$rel.children("[rid='"+rel.id+"']").html();
but that didn't work.
Thanks for any help.
If it may not be an immediate child, you'll want find
rather than children
(which only looks at immediate children):
$rel.find("[rid='"+rel.id+"']").html();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With