Support » Fixing WordPress » Add class to input fields

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    there are no input fields on the page you link to, so that makes it hard to provide accurate assistance.

    A generic solution is to use a jQuery function to add a class to all input and text area fields. Of course, this can (and probably should) be made more specific. Add the following code to at the end of your child themes functions.php file, but before a closing ?>, if any:

    function my_footer_script() { ?>
    	<script type="text/javascript">
    		jQuery(document).ready(function($) {
    			$('input, textarea').addClass('data-hj-whitelist');
    <?php }
    add_action('wp_print_footer_scripts', 'my_footer_script');

    But, assuming that you are referring to Woocommerce forms, you can use a filter to add a class, see

    For further (and without doubt better) Woocommerce specific support, I suggest you post a topic in the Woocommerce support forums:

    • This reply was modified 1 year, 2 months ago by ronaldvw. Reason: code markup fixed

    Thank you very much. It worked, i have tried on woocommerce support but haven’t recived any help. Your solution worked well. I think it will don’t cause ant trouble.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add class to input fields’ is closed to new replies.