JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li data-test="1">Test 1</li>
</ul>
<ul data-test="2">
<li>Test 2</li>
</ul>
JavaScript
alert('Accepted answer ' + $('ul').find("[data-test='" + 1 + "']").html());
alert('Second answer with users scenario ' + $("ul[data-test='" + 1 + "']").html());
alert('Second answer with working element structure ' + $("ul[data-test='" + 2 + "']").html());