Advertisement
gskorchev

DOM / articles

Feb 12th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve() {
  2.     let createTitleElement = document.getElementById('createTitle');
  3.     let createContentElement = document.getElementById('createContent');
  4.  
  5.     let createTitleValue = createTitleElement.value;
  6.     let createContentValue = createContentElement.value;
  7.  
  8.     if (createTitleValue && createContentValue) {
  9.         let titleElement = document.createElement('h3');
  10.         titleElement.textContent = createTitleValue;
  11.  
  12.         let contentElement = document.createElement('p');
  13.         contentElement.textContent = createContentValue;
  14.  
  15.         let articleElement = document.createElement('article');
  16.         articleElement.appendChild(titleElement);
  17.         articleElement.appendChild(contentElement);
  18.  
  19.         let articlesElement = document.getElementById('articles');
  20.         articlesElement.appendChild(articleElement);
  21.  
  22.         createTitleElement.value = '';
  23.         createContentElement.value = '';
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement