Javascript Ajax jQuery Html PHP Example Quiz New MORE

Onclick button add and remove class in jQuery

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <style>
        input[type=radio] {
            border: 0px;
            width: 9%;
            height: 24px;
            margin-top: 4px;
            vertical-align: middle;
        }

        .check-box_inr {
            background: orange;
            color: #303837;
            border-radius: 5px;
            padding: 7px 12px;
            margin-right: 10px;
            width: 127px;
        }

        .active {
            color: #fff;
        }
    </style>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
</head>
<body>
    <center>
        <div class="check-box_inr">
            <div class="money"> <span class="value"><b>Rs.500  </b></span>
                <input name="b" type="radio" value="1">
            </div>
        </div>
        <br>
        <div class="check-box_inr">
            <div class="money"><span class="value"><b>Rs.1,000</b></span>
                <input name="b" type="radio" value="2">
            </div>
        </div>
        <br>
        <div class="check-box_inr">
            <div class="money"> <span class="value"><b>Rs.1,500</b></span>
                <input name="b" type="radio" value="3">
            </div>
        </div>
    </center>
    <script>
        $(document).ready(function() {
            $('input').click(function() {
                $('input:not(:checked)').parent().removeClass("active");
                $('input:checked').parent().addClass("active");
            });
        });
    </script>
</body>
</html>

Run it yourself

Demo

Rs.500  

Rs.1,000

Rs.1,500