Support

Account

Home Forums Front-end Issues Adding a class to an element depending on Checkbox or Radio Button

Solved

Adding a class to an element depending on Checkbox or Radio Button

  • Hi, I’ve got a repeater field which is used to display useful links. Now I’m trying to add it so that I can make a specific link ‘featured’ (add some css to make it stand out) when I click a check box or radio button in ACF. Basically it should add a class of .featured to an element when it is checked.

    I’m a bit lost on how to implement this? Any suggestions? Thanks!

  • UPDATE: Actually already figured it out, I used the TRUE/FALSE ACF field with an IF statement inside the link’s class.

    <div class="link-item <?php if( get_sub_field('featured_link') ): ?> <?php echo 'featured'; ?><?php endif; ?>">

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Adding a class to an element depending on Checkbox or Radio Button’ is closed to new replies.