JSFiddle - React, Tailwind, and code Playground

by parush

HTML

<table>
        <tr id="1">
            <td colspan="4">
                <p class="que">
                    1. Who are you?</p>
            </td>
        </tr>
        <tr class="ans">
            <td>
                <input type="checkbox" />Student
            </td>
            <td>
                <input type="checkbox" checked="true" />Developer
            </td>
            <td>
                <input type="checkbox" />Other
            </td>
            <td>
                <input type="text" />
            </td>
        </tr>
       
    </table>

JavaScript

var answers = $('table tr.ans');
 $.each(answers, function () {
  var answer = $(this).find("input[type='checkbox']:checked").index(); 
    alert(answer);                   
  });