jQuery:点击第一个按钮后启用第二个按钮

时间:2014-03-17 13:17:53

标签: jquery

有没有办法在点击第一个按钮后启用第二个按钮?

<form method="post">
<fieldset>
    <legend>Option 1</legend>
    <input class="clickbox" type="radio" name="1" />1
    <br />
    <input class="clickbox" type="radio" name="1" />2
    <br />
</fieldset>
<fieldset>
    <legend>Option 2</legend>
    <input class="clickbox" type="radio" name="2" />1
    <br />
    <input class="clickbox" type="radio" name="2" />2
    <br />
</fieldset>
<input type="submit" value="Checkout" id="submitbutton" disabled="disabled" />
</form>

<br />
<input type="button" value="Next Button"  disabled="disabled">

DEMO ON JSFiddle

2 个答案:

答案 0 :(得分:0)

<input type="submit" value="Checkout" id="submitbutton" disabled="disabled" class="submit button" />
<input type="button" id="nextButton" value="Next Button"  disabled="disabled">

<script>
$(function() {
$("#submitbutton").click(function() {
        $('#nextButton').attr('disabled', false);
   });
});
</script>

答案 1 :(得分:0)

在这里工作:

$('form input[type="radio"]').click(function () {
    var total = $('form fieldset').length;
    $('#submitbutton').prop('disabled', ($('input:checked').length === total) ? false : true)
});

$('#submitbutton').click(function(){
    if($(this).prop('disabled') == false)
    {
        $('input[type=button]:last').prop('disabled', '');
        alert("its work!");
    }
});