Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="container">
- <br><p>Click all the fruits that you like</p>
- <div class="btn-group col-xs-12" data-toggle="buttons">
- <label class="btn btn-default">
- <input type="radio" name="apple" id="apple" value="apple">apple
- </label>
- <label class="btn btn-default">
- <input type="radio" name="pear" id="pear" value="pear">pear
- </label>
- <label class="btn btn-default">
- <input type="radio" name="orange" id="orange" value="orange">orange
- </label>
- </div>
- </div>
- $('.btn-default').click(function(e) {
- e.preventDefault();
- if ($(this).hasClass("active")) { // unclicking a clicked value
- $(this).removeClass("active").blur() // remove focus
- }
- else {
- $(this).addClass("active"); // fresh click
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement