Use images instead of radio buttons

后端 未结 8 1711
Happy的楠姐
Happy的楠姐 2020-11-22 16:47

If I have a radio group with buttons:

\"Image

... how can I show only images in the select option i

8条回答
  •  粉色の甜心
    2020-11-22 17:31

    Keep radio buttons hidden, and on clicking of images, select them using JavaScript and style your image so that it look like selected. Here is the markup -

    and JS

     $(".image-radio img").click(function(){
         $(this).prev().attr('checked',true);
     })
    

    CSS

    span.image-radio input[type="radio"]:checked + img{
        border:1px solid red;
    }
    

提交回复
热议问题