JSFiddle - React, Tailwind, and code Playground
HTML
<div id="myElement">
<div>
<div>
<ul>
<li></li>
<li><div data-custom-property="12345">
<p>
Some details
</p>
<div>
<div>
<div data-custom-property="xyzwt">
Stuff
</div>
</div>
</div>
</div></li>
<li></li>
</ul>
</div>
</div>
</div>
<button onclick="return getFirstElementWithProperty('data-custom-property');">
Get Element
</button>
JavaScript
function getFirstElementWithProperty(propertyName) {
var element = $('#myElement').find('?');
console.log(element);
}