Conditional wp_add_inline_script

0 Replies ·

  1. Hi Justin,

    I am trying to build a conditional inline script to hide some elements in a registration form.

    I want to check for the presence of a div with the class spco-attendee-ticket-910
    and, if found, then hide the div with the class ee-reg-qstn-34-input-dv

    Here is a piece of JQuery code I tried but the hasClass() method does not seem to return anything :

    function rc_ee_hide_custom_questions_convention() {
                wp_add_inline_script( 
                    'single_page_checkout',
                    'jQuery( document ).ready( function( $ ) {  
                        if ( $("div").hasClass(".spco-attendee-ticket-910") ) {
                            $(".ee-reg-qstn-34-input-dv").hide();
                        }
                    });'
                );
    }
    add_action( 'wp_enqueue_scripts', 'rc_ee_hide_custom_questions_convention', 99 );
    

    Am I missing something ?

    Thanks in advance for your help !

    Patrick