capture value input text javascript

2

So I'm studying oop in javascript to crawling yet, for this I'm trying to add elements to my site dynamically through js

I want to capture the value of my text field and when I click on the add button the element will be created follow the code created in jsfiddle

link

    
asked by anonymous 24.12.2016 / 22:24

1 answer

4

The mistake you made was to get the value of input direct in the constructor of the class. Since the class is called at the beginning of the page, this.add will always be an empty value. What you need to do is get the value of input whenever it is clicked on button .

Here's how: link

    
24.12.2016 / 22:46