Skip to content
Advertisement

Display DIV’s on Click

I have 2 div elements, and I want to add something on the Div 2 that when I Click on that Div, it will Display Div 1, so both DIV’s will be visible when clicking Div 2! Div 2 should remain visible all the time, but when I click on DIV 2, it should display Div 1!

I want a JS script!

JavaScript
JavaScript

Advertisement

Answer

Here we go https://jsfiddle.net/byr0kqL5/

The simple function

JavaScript

but you need to add this style

JavaScript

Your box 1 will be like this

JavaScript

Lastly, your box 2 needs to have onclick event

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement