JSFiddle - React, Tailwind, and code Playground
HTML
<form>
<label>Label 1</label><input type="text" name="field1" /><br />
<label>Label 2</label><input type="text" name="field2" /><br />
<label>Label 3</label><input type="text" name="field3" /><br />
<label>Label 4</label><input type="text" name="field4" /><br />
<label>Label 5</label><input type="text" name="field5" /><br />
<button type="button" id="btnTest">Report</button>
</form>
<div id="Output"></div>
JavaScript
$(document).ready(function() {
$("#btnTest").click(function() {
var texts = [];
$("form label").each(function() {
var oLabel = $(this);
var oInput = oLabel.next();
texts.push(oLabel.text() + " - " + oInput.val());
});
$("#Output").html(texts.join("<br />"));
});
});