Help needed with Javascript

by 3 replies
4
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
#programming #javascript #needed
  • document.getElementById("div1").innerHtml = "";

    I think that should do.

    Am not sure.

    Prateek
    PDJSolutions
  • 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
  • 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 .

Next Topics on Trending Feed