开发者

jQuery toggle class of label when radio button is clicked

开发者 https://www.devze.com 2023-04-02 08:40 出处:网络
I have a label surrounding my radio button where the background is supposed to change on :hover and :focus

I have a label surrounding my radio button where the background is supposed to change on :hover and :focus

<label for="radio1" class="radio-blur">
<input name="j开发者_如何学运维ob" id="radio1" value="1" type="radio"> Graphic Design</label>

I want to change the class from .radio-blur to .radio-focus

I have

    $(document).ready(function(){
        $('input:radio').click(function() {
            $(this).parent('label').toggleClass('.radio-focus');
        });  
    }); 

But it doesn't work... please help


Remove the dot in the class

$(this).parent('label').toggleClass('radio-blur radio-focus');

JSFiddle

0

精彩评论

暂无评论...
验证码 换一张
取 消