JSFiddle - React, Tailwind, and code Playground

HTML

<div>
    <div id="Q01">
        <p>Some text</p>
    </div>
    <div id="Q02">
        <p>Some text</p>
    </div>
    <div id="Q03">
        <p>Some text</p>
    </div>
     <div id="Q03">
        <p>Some text</p>
    </div>
    <label for="number">Number of DIVs:</label>
    <input type="number" name="result" id="number" />
</div>

JavaScript

$(function () {
    var result = $('[id]').length;

    $('input[name=result]').val(result);
});