Help needed with Javascript

3 replies
I need a javascript code to write the id of the div where the code is placed. For example:

<div id="div1"><script type="text/javascript">.....</script></div>
The code will write: div1
And when i change the id of the div the code will write the new id
please help me
#javascript #needed
  • Profile picture of the author pdjsolutions
    document.getElementById("div1").innerHtml = "";

    I think that should do.

    Am not sure.

    Prateek
    PDJSolutions
    {{ DiscussionBoard.errors[1399131].message }}
  • Profile picture of the author coolboycsaba
    the problem is i don`t know the div id beacause i want to use this code for comments on a blog , each comment has a different div id
    Signature
    {{ DiscussionBoard.errors[1399720].message }}
  • Profile picture of the author da1fitz
    Because Js is clientside only and your looking to create a unique reference for each div presumably from different client machines, I think that the only way todo this will be to grab your div number from a database or maybe server based text file using an ajax call, write your div, ++ the div number then write it back to the server once again using an ajax call. As ever nothing is simple .
    {{ DiscussionBoard.errors[1400456].message }}

Trending Topics