Support » Plugin: Advanced Custom Fields » How to add Javascript Code to an Advanced Custom Field?

  • marlosb

    (@marlosb)


    Hi, I’m trying to do a simple test to understand how Advanced Custom Field works with Java script code.

    I created a Text Area Field and added this code below:

    <h1 id=”myH”></h1>
    <p id=”myP”></p>

    <script>
    /*
    The code below will change
    the heading with id = “myH”
    and the paragraph with id = “myP”
    */
    document.getElementById(“myH”).innerHTML = “JavaScript Comments”;
    document.getElementById(“myP”).innerHTML = “My first paragraph.”;
    </script>

    As a result on the front end of my website instead of seeing:

    JavaScript Comments

    My first paragraph.

    I am seeing this:

    /* The code below will change the heading with id = “myH” and the paragraph with id = “myP” */ document.getElementById(“myH”).innerHTML = “JavaScript Comments”; document.getElementById(“myP”).innerHTML = “My first paragraph.”;

    What am I doing wrong and how to solve it?

    I’d be very very grateful if you could help me over here,

    Thanks

    Marlos

    • This topic was modified 4 months ago by marlosb.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.