Support

Account

Home Forums Front-end Issues Display color name with color picker Reply To: Display color name with color picker

  • I share my code for those who want

    PHP

     <?php if( have_rows('field_name_repeater') ): ?>
    <?php while( have_rows('field_name_repeater') ): the_row(); 
    $color = get_sub_field('fied_colorpicker');
    ?>
    
    <div class="color-repeat" data-color="<?php  echo $color; ?>">
    <div class="colorName"></div>
    </div>
    
    <?php endwhile; ?>
    <?php endif; ?>

    JS :

    $('.color-repeat').each(function( ) {
    	var color = $(this).data( "color" );
    	var n_match  = ntc.name(color);
    	n_name       = n_match[1]; // Text string: Color name
    	$(this).find(".colorName").text(n_name);
    });