简体   繁体   中英

jQuery toggle class of label when radio button is clicked

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="job" 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM