get row td id by td's checkbox change

HTML

<table>
    <thead>
    <tr id="mq">
        <td><input type="checkbox" /></td>
        <td>firstname</td>
        <td>secondname</td>
        <td>lastname</td>
    </tr>
    </thead>
    <tbody>
        <tr id="1">
        <td><input type="checkbox" /></td>
        <td>lorem</td>
        <td>ipsum</td>
        <td>css</td>
        </tr>
        <tr id="2">
        <td><input type="checkbox"  /></td>
        <td>lorem</td>
        <td>ipsum</td>
        <td>css</td>
        </tr>
        <tr id="3">
        <td><input type="checkbox" /></td>
        <td>lorem</td>
        <td>ipsum</td>
        <td>css</td>
        </tr>
        <tr id="4">
        <td><input type="checkbox" /></td>
        <td>lorem</td>
        <td>ipsum</td>
        <td>css</td>
        </tr>
        <tr id="5">
        <td><input type="checkbox"  /></td>
        <td>lorem</td>
        <td>ipsum</td>
        <td>css</td>
        </tr>
    </tbody>
</table>
<button id="thechecked">Get Checked</button>

CSS

tr,td{border:1px solid black;}

JavaScript

$("input[type='checkbox']").on("click", function () {
    if ($(this).is(':checked')) {
        var id = $(this).closest('tr').prop('id');
        alert(id);
    }
});