Forums

Get Page or Post ID from JavaScript (1 post)

  1. eloyrubio
    Member
    Posted 4 months ago #

    I want to get a Post id from a javascript function in the post editor. I tried this code, but does not work for me:

    <script>
    function get_post_content(){
       return document.getElementById("post-"+id).innerHTML;
    }
    </script>
    
    <a href="#" onclick="get_post_content(<?php the_ID(); ?>);">Next</a>

    Thank you in advance.

Reply

You must log in to post.

About this Topic