I am trying to validate a matrix table with inputs that accept only 1 and 0.
I want to validate each row. How can i determine the value of each td of each row on button click?
Edit Thanks to @ Abhilash Ravindran C K i have updated my javascript code. Now i want to grab those values and use them in condition.
$('#checkMatrix').click(function(e){
$("tr").find("td input").each(function() {
document.write(this.value);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="Matrix">
<tr id="Matr1">
<td>1</td>
<td><input type="number" min="0" max="1" step="1"></td>
<td><input class="increment-30-gray" type="number" min="0" max="1" step="1"></td>
<td><input type="number" min="0" max="1" step="1"></td>
<td><input type="number" min="0" max="1" step="1"></td>
</tr>
<tr id="Matr2">
<td>2</td>
<td><input type="number" min="0" max="1" step="1"></td>
<td><input class="increment-30-gray" type="number" min="0" max="1" step="1"></td>
<td><input type="number" min="0" max="1" step="1"></td>
<td><input type="number" min="0" max="1" step="1"></td>
</tr>
</table>
<button id="checkMatrix">Check</button>
<h4>Answers:<br> 1,0,0,1<br>0,0,1,0</h4>
Answers:
Row1: 1,0,0,1
Row2: 0,0,1,0
});$('#Matrix tr').eq(0).find('input'). Loop over the result using.each, and grab the values using$(this).val()inside the function.if($(this).val() === 1001)