Execute a document.ready in functions.php

admin

Administrator
Staff member
I need to run a script after a hook is fired in my functions.php file. Im using a wordpress mailchimp plugin, I need to do some text inserts and
Code:
display = "none"
, etc, in the html:

Code:
add_action( 'mc4wp_form_success', function() {
   // do something
     echo '<script type="text/javascript">',
        'console.log("starting....");', // this works
     'document.getElementById("mailchimp-is-subscribed").style.display = "none";',
         'document.getElementById("mailchimp-success-form").style.display = "block";',
         'console.log("end");',
     '</script>';
});

The error I got was
Code:
style
is
Code:
null
. I assume the document is not ready?
Code:
$
does not work. <strong>Am I doing this wrong?</strong> I need to run that code after that hook is called. Putting the code in
Code:
.js
file works great. Thanks