<script>
document.addEventListener('DOMContentLoader', function(){
document.getElementById('getMessage').onClick=function(){};
});
</script>
onclick
? worked for me
<script>
document.addEventListener('DOMContentLoader', function(){
document.getElementById('getMessage').onclick=function(){};
});
</script>
let navEl = document.createElement("nav");
let brandEl = document.createElement("div");
let brandTag = document.createElement("a");
let navLinksEl = document.createElement("ul");
let liEls = document.createElement("li");
navLinksEl.className = "nav-links";
navLinksEl.appendChild(liEls);
navLinksEl.appendChild(liEls);
navLinksEl.appendChild(liEls);
brandTag.href="#";
brandEl.className = "brand";
let titleEl = document.createTextNode("Javascript Page");
document.body.appendChild(navEl).appendChild(brandEl).appendChild(brandTag).appendChild(titleEl);
navEl.appendChild(navLinksEl);
heres the full code
function Book(title, author, isbn) {
this.title = title;
this.author = author;
this.isbn = isbn;
}
function UI() {}
UI.prototype.addBookToList = function(book) {
const list = document.getElementById('book-list');
const row = document.createElement('tr');
row.innerHTML = <td>${book.title}</td>
<td>${book.author}</td>
<td>${book.isbn}</td>
<td><a href="#" class="delete">X </a></td>
;
list.appendChild(row);
};
UI.prototype.showAlert = function(message, className) {};
UI.prototype.clearFields = function() {
document.getElementById('title').value = '';
document.getElementById('author').value = '';
document.getElementById('isbn').value = '';
};
document.getElementById('book-form').addEventListener('submit', function(e) {
const title = document.getElementById('title').value,
author = document.getElementById('author').value,
isbn = document.getElementById('isbn').value;
const book = new Book(title, author, isbn);
const ui = new UI();
if (title === '' || author === '' || isbn === '') {
ui.showAlert('Please fill all', 'error');
} else {
ui.addBookToList(book);
ui.clearFields();
}
e.preventDefault();
});