X something out

Justin

Legendary Typer
Joined
Jul 2, 2009
Messages
13,882
Reaction score
1
FP$
106
How would I make a div box where:
The div box is shown, and in the corner, a red x is in a specified place
When the x is clicked - it closes that div box
Content on the page moves up

I am rusty on Javascript. Thanks.
 
No problem, glad I could have helped. 🙂 If you need help with the CSS feel free to ask, I love working with css and customizing scripts. 🙂
 
You need to do this in javascript, here is the basic way to do this, though you will have to style it correctly (the box) with CSS.

Your "x" will be a link, which you can do two ways to call the javascript code, I usually put it in the href portion, but you can make it one of the two ways below:

Code:
<a href="javascript:close('THE DIV's ID NAME');" title="Close This Box">X</a>

or

Code:
<a href="" title="Close This Box" onmouseout="close('THE DIV's ID NAME')">X</a>

You will then need this javascript code, either put it in the page or make it an external document

Code:
function close(theDiv) {
    document.getElementById(theDiv).style.display = "none";
}

Notice that the div's id refers to the actual ID you give the div, so for example, we will call it thisBox as shown below

Code:
<div id="thisBox">
YOUR "x" LINK
</div>
 
Back
Top Bottom