January 2nd, 2013, 06:08 PM
Inject new div into the page
var temp = 1;
document.getElementById('display').innerHTML +="<div id = \"temp\"> Here will be some image that will go to that div </div>
I'm using the above code to inject a new div that has some images in to the " display " div in the body of the page.
the div id is set t a java script variable that changes. I tried the above and other syntax and it did not work.
<div id = \"temp\"></div>
I want the div id name to increase every time this function is called.
January 3rd, 2013, 08:54 AM
You need to increment the "temp" variable; like so:
var temp = 0;
document.getElementById("display").innerHTML += "<div id = \""+temp+"\"> Here will be some image that will go to that div </div>";
<input type="button" value="Inject New Content" onclick="injectDIV()"/>
January 3rd, 2013, 06:02 PM
I was missing to add the + variable +. The plus sign and this caused me lots of time.
What is a good way of learning java script and all syntax
January 3rd, 2013, 08:55 PM
Most online JS tutorials seem to be out-dated - unless someone can recommend an up-to-date site?
Originally Posted by yousg27
extension is deprecated as of PHP 5.5.0, and is not recommended for writing new code as it will be removed in the future. Instead, either the mysqli or PDO_MySQL extension should be used." the docs