![]() | | ||||||||
| | #1 |
| Active Warrior Join Date: May 2009
Posts: 69
Thanks: 10
Thanked 0 Times in 0 Posts
|
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 |
| | |
| | |
| | #2 |
| Coding Expert !! :D War Room Member Join Date: May 2009 Location: India
Posts: 178
Thanks: 14
Thanked 15 Times in 12 Posts
|
document.getElementById("div1").innerHtml = ""; I think that should do. Am not sure. Prateek PDJSolutions |
| | |
| | |
| | #3 |
| Active Warrior Join Date: May 2009
Posts: 69
Thanks: 10
Thanked 0 Times in 0 Posts
|
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
|
| | |
| | |
| | #4 |
| Paul Fitzpatrick War Room Member Join Date: Apr 2009
Posts: 100
Thanks: 38
Thanked 7 Times in 7 Posts
|
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 .
|
| | |
![]() |
|
| Tags |
| javascript, needed |
| Thread Tools | |
| |
![]() |