0%

单选框表单提交

<div>
    <label class="radio-inline">
        <input type="radio" name="expire" th:value="1" th:checked="true"/>6小时
    </label>
    <label class="radio-inline">
        <input type="radio" name="expire" th:value="2"/>12小时
    </label>
    <label class="radio-inline">
        <input type="radio" name="expire" th:value="3"/>1天
    </label>
    <label class="radio-inline">
        <input type="radio" name="expire" th:value="4"/>3天
    </label>
    <label class="radio-inline">
        <input type="radio" name="expire" th:value="5"/>7天
    </label>
</div>

表单提交时如何获取用户选中了哪个单选框呢?

var expire = $("input[name='expire']:checked").val();