+ 4

I want to make button with div

when I will click in button my div will show I think I can do it with display none and block after in div I will have a two input type text and one button (ok)when I will write text in both text area and will click my ok button text will show in second div which will open when I will click my Ok button

28th Apr 2017, 2:25 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
9 Answers
+ 13
I want to help you but i didn't understand anything, can you write your question with more clarity? Maybe with an example of what you want to do. If you want to create a toggle effect with a div, yeah... you can make it with the display property. If you want to display a div when you click on the submit button, yeah... you can make it with the onsubmit() function in Javascript.
28th Apr 2017, 2:41 PM
Maz
Maz - avatar
+ 6
<div> <input type="button" name="any" value="button" /> </div> the answer is very simple try it and enjoy it..
28th Apr 2017, 2:40 PM
Vansh
Vansh - avatar
+ 6
What's your question ? I think you have done it, the way you are approaching is correct. On click of button, you have to get the value of input box and set it to innerHTML of div element. Also, this is the point you will set the display: block property of div. [Edit]: JS part: //function called on click of button function showText(){ var div = document.getElementById('your_div_id'); div.style.display = 'block'; div.innerHTML = document.getElementById('your_input_id').value; }
28th Apr 2017, 2:42 PM
Ashwani Kumar
Ashwani Kumar - avatar
+ 5
@Kristina see my edited answer. You will get an idea.
28th Apr 2017, 3:06 PM
Ashwani Kumar
Ashwani Kumar - avatar
+ 3
second answer just type <div> <button> My Button </button> </div> very simple
28th Apr 2017, 2:54 PM
Vansh
Vansh - avatar
+ 2
guys first in html we have a button with dive star my div will have a none display after when I will click in button my div will show
28th Apr 2017, 2:43 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 2
div have a two text input and one button ok when I will write text in inputs and doing ok button my text will add my second new div
28th Apr 2017, 2:46 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 2
I want to know how working javascript only
28th Apr 2017, 3:05 PM
Kristina Hakobyan
Kristina Hakobyan - avatar
+ 2
Yeah have but after I will add it my code
28th Apr 2017, 3:08 PM
Kristina Hakobyan
Kristina Hakobyan - avatar