Skip to content

Turn any text input field into a color picker with jQuery

I needed this functionality in forminator. Unfortunately this plugin does not support color picker inputs. But HTML5 and jQuery came to the rescue. Just specify the input with a class or ID and dump in this code snippet:

function enym_colorpicker() {
?>
<script type="text/javascript">
	jQuery(document).ready(function($) {

		//CHANGE COLOR TYPE ON INPUT WITH CLASS colorpicker
		jQuery(".colorpicker input").prop("type", "color");
	});
</script>
<?php
}

add_action( 'wp_footer', 'enym_colorpicker' );

The result will look like this:

Create a beautiful color picker from any input form field with JQuery

Dieser Beitrag hat 0 Kommentare

Schreibe einen Kommentar

Deine E-Mail wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

An den Anfang scrollen