Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There's no standard <code>show_my_div</code> function in PHP or JavaScript. You'd have to post the content of that function for anyone to help you with it.</p> <p>Outputting a div is easy in PHP:</p> <pre><code>echo "&lt;div&gt;content&lt;/div&gt;"; </code></pre> <p>Similarly, it's easy in JavaScript to create a div element and append it to something. Here's raw JavaScript to append a div to the end of the page:</p> <pre><code>var div = document.createElement('div'); div.innerHTML = "The content of the div"; document.body.appendChild(div); </code></pre> <p>You can append elements anywhere, not just at the end. For instance, suppose I have a div with the id <code>foo</code>:</p> <pre><code>&lt;div id="foo"&gt;&lt;/div&gt; </code></pre> <p>...and I want to add a paragraph to the end of it:</p> <pre><code>var p, div; div = document.getElementById('foo'); if (div) { // (Just being defensive) p = document.createElement('p'); p.innerHTML = "The text of the paragraph"; div.appendChild(p); } </code></pre> <p>These things are made easier if you use a JavaScript library like <a href="http://prototypejs.org" rel="nofollow noreferrer">Prototype</a>, <a href="http://jquery.com" rel="nofollow noreferrer">jQuery</a>, <a href="http://code.google.com/closure/library" rel="nofollow noreferrer">Closure</a>, or <a href="http://en.wikipedia.org/wiki/List_of_JavaScript_libraries" rel="nofollow noreferrer">any of several others</a> to smooth out browser differences and give you some syntactic sugar.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload