JSFiddle - React, Tailwind, and code Playground
HTML
<div id="test22">
<span id="content22">Click to add the value</span>
<input type="hidden" id="hidden22" value="hello">
</div>
<div id="test33">
<span id="content33">Click to add the value</span>
<input type="hidden" id="hidden33" value="world">
</div>
<input type="text" id="show">
JavaScript
$("span[id^=content]").click(function(){
$("#show").val($("#hidden"+this.id.substr(-2)).val());
});