If I understand your question you wish to obtain the value of input elements from within a table? and you wish to return the value for all of them separately? html
is used to obtain to contents of an element i.e:
$(function() {
$("div.header").html();
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="headercontainer">
<div class="header">Hello World!</div>
</div>
would return :
Hello World!
I think it would be best to look at https://api.jquery.com/html/ for more info as it can also be used to show the actual html within a container etc.
One approach to getting values for each input field would be making use a class
that is similar for each input, you can have several classes separated by a space which can then be called upon. Something like this:
function Myfunc() {
var totals = 0;
$(".classa").each(function() {
totals += +$(this).val();
});
$("#total").val(totals);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<tr>
<td>
<form>
<input type="text" class="classa classb classc" value="1" id="id1">
<input type="text" class="classa classd classe" value="2" id="id2">
<input type="text" class="classa classf classg" value="3" id="id3">
</form>
</td>
</tr>
</table>
<br>
<input type="button" class="button" id="getvalue" value="Add up values!" onclick="Myfunc()">
<br>
<label for="total">
<input type="text" class="total" id="total">
</label>
Alternatives if you wish to add text values together to make a sentence perhaps something like this would be of more interest to you :
function Myfunc() {
var first = $("input.classb").val();
var second = $("input.classd").val();
var third = $("input.classf").val();
var sumtext = (first + ' ' + second + ' ' + third );
$("#totsent").val(sumtext);
console.log(first);
console.log(second);
console.log(third);
console.log(sumtext);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<table>
<tr>
<td>
<form>
<input type="text" class="classa classb classc" value="Hello" id="id1">
<input type="text" class="classa classd classe" value="Beautiful" id="id2">
<input type="text" class="classa classf classg" value="World!" id="id3">
</form>
</td>
</tr>
</table>
<br>
<input type="button" class="button" id="getvalue" value="Add up text!" onclick="Myfunc()">
<br>
<label for="totsent">
<input type="text" class="sentence" id="totsent">
</label>
Maybe this answer helps, maybe it doesn't, I'm still fairly new to Jquery and JavaScript but i hope it does.