Posts o[css] html radio buttons with image states
Post
Cancel

o[css] html radio buttons with image states

references http://www.tutorialrepublic.com/twitter-bootstrap-tutorial/bootstrap-buttons.php

http://bootsnipp.com/snippets/featured/image-checkbox-buttons

using css3 - http://stackoverflow.com/a/26737044

  1. sample bootstrap html ```js //http://www.tutorialrepublic.com/codelab.php?topic=bootstrap&file=buttons-radio
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
        <div class="btn-group" data-toggle="buttons">
            <label class="btn btn-default btn-bimary">
                <input type="radio" id="page_cat_radio_1" name="page_cat_radio" value="1">  ![](img/page_cat_a.png)
            </label> 
            <label class="btn btn-default btn-bimary">
                <input type="radio" id="page_cat_radio_2" name="page_cat_radio" value="2"> ![](img/page_cat_b.png)
            </label> 
            <label class="btn btn-default btn-bimary">
                <input type="radio" id="page_cat_radio_3" name="page_cat_radio" value="3"> ![](img/page_cat_c.png)
            </label> 

            <label class="btn btn-default btn-bimary">
                <input type="radio" id="page_cat_radio_4" name="page_cat_radio" value="4"> ![](img/page_cat_d.png)
            </label> 
            <label class="btn btn-default btn-bimary">
                <input type="radio" id="page_cat_radio_5" name="page_cat_radio" value="5"> ![](img/page_cat_e.png)
            </label> 
            <label class="btn btn-default btn-bimary">
                <input type="radio" id="page_cat_radio_6" name="page_cat_radio" value="6"> ![](img/page_cat_f.png)
            </label> 
        </div> ```
  1. sample plain html ```js //http://jsbin.com/image-instead-of-radio-button/3/edit

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Javascript is unique for the samples^
```js
//FYI - when form submitted also get page_cat_radio = x value,
//where x is the checked - proof http://jsfiddle.net/KyleMit/0nevkwyn/

//manually get the value
//http://www.tutorialrepublic.com/faq/how-to-get-the-value-of-selected-radio-button-using-jquery.php
alert($("input[name='page_cat_radio']:checked").val());

//manually set the value
//http://stackoverflow.com/a/26191899
var aEls = $('[name=page_cat_radio]');
//aEls.prop('checked', false).parent().removeClass('active');
aEls.eq(1).prop('checked', true).parent().addClass('active');

finally use http://screwdefaultbuttons.com/ or http://github.com/mattSOLANO/ScrewDefaultButtonsV2

origin - http://www.pipiscrew.com/?p=2703 css-radio-buttons-images

This post is licensed under CC BY 4.0 by the author.
Contents

Trending Tags