Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Main {
- // Конструктор
- constructor() {
- // input1, input2, button
- this.book = document.querySelector('.form-todo').children[0];
- this.author = document.querySelector('.form-todo').children[1];
- this.btn = document.querySelector('.form-todo').children[2];
- }
- // Проверка
- check() {
- this.btn.addEventListener('click', (e) => {
- e.preventDefault();
- if ( this.book.value == '' || this.author.value == '' ) {
- console.log('null');
- } else {
- this.add();
- }
- });
- }
- // Добавить новую книгу
- add() {
- let array = [{
- book: 'Красная Таблетка',
- author: 'Андрей Курпатов'
- }];
- array.push({
- book: this.book.value,
- author: this.author.value
- });
- console.log(array);
- }
- }
- let main = new Main();
- main.check();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement