- This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
Viewing 3 posts - 1 through 3 (of 3 total)
- The forum ‘JavaScript’ is closed to new topics and replies.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › JavaScript › addClass with pure JavaScript
Hey guys. Quick question. I’m working on a little app to help me get my JS game up and to use with responsive design. Basically, it just gives you the page width and height when I resize the window. Everything went good but when I tried to add a ‘close’ element I found myself a bit stuck. Simple setup, when I click the ‘close’ element I want to fade out the whole div. The way it is now is that when I click the ‘close’ element, only that element fades out. My question is what would be the most efficient way to achieve the result of the whole div fading out? Side note: If some of the code looks familiar it’s because I used some from the snipper section of this site (credit is given where credit is due as always). Also, while in code pen it won’t give me the pixel numbers live. I have to change the window size, reload, then I get the right numbers. I apologize in advance if that makes this harder. Thanks for any help as always guys.
function closeMe() {
var close = document.getElementById('close');
var box = document.getElementById('box');
close.onclick = function() {
box.className = 'hide';
}
}
// Add id="box" to the div you want to hide
Glad everything worked out.