带有jquery的活动单选按钮

I used all of the helpful answers on this site to try to build a jquery script to select radio buttons, but for some reason they don't work. Am I doing something wrong? For the sake of simplicity I've started back from square one.

I've attached the format that the php-generated form produces below. I tried multiple browsers, but was unable to get any button to select anything. Is there some complexity I'm not taking into account? The page is a .php page, and the form is generated in php.

Sorry for the basic question -- any help would be greatly appreciated. Not sure if it's relevant, but I want these buttons to work on mobile as well as various browsers.

Form Code:

    <form class="form-horizontal" method="get" action="submit.php" name="form">
    <div class="control-group">
        <div class="row-fluid">
            <div class="span2"></div>
            <div class="span8">
                <label class = "control-label" for="input1"> foreign policy </label>

                <div class="controls">
                    <label class="checkbox inline"><input type="radio" name="group1" id="1_l" value="1_l"> Liberal</label>
                    <label class="checkbox inline"><input type="radio" name="group1" id="1_m" value="1_m"> Moderate</label>
                    <label class="checkbox inline"><input type="radio" name="group1" id="1_c" value="1_c"> Conservative</label>
                </div>
            </div>
        </div>

        <div class="row-fluid">
            <div class="span2"></div>
            <div class="span8">
                <br>
                <center><button type="submit" class="btn btn-danger btn-large">Generate</button></center>
            </div>
            <div class="span2"></div>
        </div>
</form>

Jquery Code:

$('button').click(
function() {
    $('#1_l').attr('checked', true);
}
);

Make sure to only bind the handler after the DOM has been loaded:

$(function() {
  $('button').click(function() {
    $('#1_l').attr('checked', true);
  });
});

Use the ":checked" selector in jQuery to select the checked input, otherwise you only get the first one.

$(function () {

    $('button.btn').click(function () {
        var $box = $('.checkbox input:checked');
        if ($box.length > 0)
            alert($box.val());
    });

});​

Here is what i see you have a div that was not closed i closed it

I changes the button type to button rather than submit so i could see it work and all was good

See my working DEMO

<form class="form-horizontal" method="get" action="submit.php" name="form">
    <div class="control-group">
        <div class="row-fluid">
            <div class="span2"></div>
            <div class="span8">
                <label class = "control-label" for="input1"> foreign policy </label>

                <div class="controls">
                    <label class="checkbox inline"><input type="radio" name="group1" id="1_l" value="1_l"> Liberal</label>
                    <label class="checkbox inline"><input type="radio" name="group1" id="1_m" value="1_m"> Moderate</label>
                    <label class="checkbox inline"><input type="radio" name="group1" id="1_c" value="1_c"> Conservative</label>
                </div>
            </div>
        </div>

        <div class="row-fluid">
            <div class="span2"></div>
            <div class="span8">
                <br>
                <center><button type="button" class="btn btn-danger btn-large">Generate</button></center>
            </div>
            <div class="span2"></div>
        </div>
    </div>
</form>​

and here is the jQuery

$(function () {
    $('button').click(function() {
        $('#1_l').attr('checked', true);
    });​
}