Jquery Use Image As CheckBox

前端 未结 6 1106
情话喂你
情话喂你 2021-01-07 08:59

I am in pursuit of implementing images as checkboxes. For now I am trying out a sample. The code below contains a simple image with a submit button next to it. On clicking t

6条回答
  •  醉酒成梦
    2021-01-07 09:36

    $('#blr').on('click', function(e) {
        var $this = $(this),
            $imgCheck = $(this).next().attr('checked'),
            border_styles = ['solid 2px red', 'none']
            is_checked = $imgCheck.attr('checked');
        $this.css('border', border_styles[is_checked]);
        $imgCheck.attr('checked', !is_checked);
    })
    

提交回复
热议问题