JSFiddle - React, Tailwind, and code Playground

by snover

HTML

<div id="foo">
    <span>(foo)</span>
</div>
<div id="result"></div>
<div id="expected">0 1 1 1</div>

JavaScript

try {
    $('#result').append($('#foo :has(:nth-child(1))').length + ' ');
    $('#result').append($('#foo:has(:nth-child(1))').length + ' ');
}
catch (e) {
    $('#result').append(e + ' ');
}

try {
    $('#result').append($('#foo :contains("(foo")').length + ' ');
    $('#result').append($('#foo :contains(\\(foo)').length + ' ');
}
catch (e) {
    $('#result').append(e + ' ');
}