Hiding radio buttons and styling labels with jQuery

    [javascript]
    <html>
    <head>
    <script type="text/javascript">
    $(document).ready(function () {
    $(‘input’).click(function () {
    $(‘input:not(:checked)’).parent(‘label’).removeClass("style1");
    $(‘input:checked’).parent(‘label’).addClass("style1");
    });
    });​
    </script>
    <style>
    input {display: none}
    .style1 {background: red;}​
    </style>
    </head>
    <body>
    <label><input type="radio" name="newsletter" />Hourly</label>
    <label><input type="radio" name="newsletter" />Daily</label>
    </body>
    </html>
    [/javascript]

    Leave a Reply