I have a button called WatchMode.
When you click this button, it will close certain divs, specified by the div ID.
The javascript for this is as follows:
function watchmode() {
document.getElementById('aps30').innerHTML = " ";
}
Now, I want to do the same for a div that appears twice on my page, this div has a Class instead of an ID.
I tried adding this line to the javascript, but it doesn’t seem to work
document.getElementByClassName('floater').innerHTML = " ";
Any suggestions ??
You have to change a number of things:
Here’s the code:
This is a place where jQuery is really useful. In jQuery, it would just be:
That would automatically find all objects with that class and set the innerHTML of all matching objects to your string.