0
What is wrong with this code? - - <!Doctype html> <head> </head> <body> <form> <input type="text" id="input"> </form> <button type="button" id="button">Click here</button> <script> var input=document.getElementById("input"); var button=document.getElementById("button"); function display() { if (button.clicked == true) { console.log("input"); } }; display(); </script> </body>
Need someone for debugging
6 Réponses
+ 2
Where did you get "button.clicked" from? I don't see it anywhere else in your code. Also, there's nothing in your code that registers a click when you actually click the button. You need an event handler.
+ 2
take a look a this, it's a basic example of exactly what you are trying to do.
http://www.w3schools.com/jsref/event_onclick.asp
+ 1
you are calling display function at script when it load and you are testing conditions that does button pressed or not so it will be false conditions so it won't work
0
thanx...but i still dont get it
0
hi Thomaz, what do you want with the code? a button that if is clicked you receive a message o console with text inserted on input box, is it?
so we insert a text on input box and pressing the button, the text is show on console.log. is that??
0
guys how will I run a function in JavaScript that after clicking submit it will take me to another page if the condition is true