Element types?

Can be anything, so <div id=”, <span id=”, <p id=”, etc

N.B. You need to place the <script> after the HTML element, or call it within say window.onload = function() (the div or whatever tag you’ve used must be before the javascript on the page)

In your html
<div id="my_target_div"></div>

To manipulate text within a block of text you could you span instead of div

In your javascript – Referencing by ID Name
document.getElementById('MyTargetIdName').innerHTML = "<p>Hello</p>";


<script>document.getElementById('MyTargetIdName').innerHTML = "<p>Hello</p>";</script>
In your javascript – Referencing by Class Name
document.getElementsByClassName('MyTargetClassName')[0].style.visibility = "visible" ;
//When you getElementsByClassName an array is retutrned, because there can be more than one element using the same class.
If using jquery


Note that this will overwrite if you already have content between the div tags

Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.


Your email address will not be published. Required fields are marked *