Support

Account

Home Forums Backend Issues (wp-admin) How to change text on a button when loading a block in JS safe mode?

Unread

How to change text on a button when loading a block in JS safe mode?

  • I need help with my code. I’m trying to find a way to change the text on a button. It has to be in a safe mode as it’s the only way JS code can be executed on WordPress on the back-end “Admin”.

    Here’s the PHP code that’s in the block:

    <div id="click_show" class="acf-field acf-field-button-group acf-field-5ffec954d28f0" data-name="button_click" data-type="button_group" data-key="field_5ffec954d28f0" data-conditions="[[{&quot;field&quot;:&quot;field_5f8bec0f9f45d&quot;,&quot;operator&quot;:&quot;!=empty&quot;}]]">
       <div class="acf-input">
          <div class="acf-button-group"><label class="selected">Show details</label></div>
       </div>
    </div>

    And what I’m trying to change text in the <label> from ‘hide details’ to ‘show details’

    My JS code:

    jQuery(document).ready(function ($) {
      $(document).on("change", "#click_show", function() {
        $("#click_show .acf-input .acf-button-group label.selected").text("Hide details 5");
      });
    });
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.