Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function deleteByEmail() {
- const tableTbodyElment = document.querySelector('#customers tbody');
- const tableTrElements = document.querySelectorAll('#customers tbody tr');
- const inputEmailELement = document.querySelector('input[name=email]');
- const result = document.querySelector('#result');
- let notFound = true;
- if (!inputEmailELement.value) {
- return;
- }
- [...tableTrElements].forEach((tr) => {
- const [, email] = tr.querySelectorAll('td');
- if (email.innerText === inputEmailELement.value) {
- tableTbodyElment.removeChild(tr);
- notFound = false;
- result.innerText = 'Deleted.';
- }
- });
- if (notFound) {
- result.innerText = 'Not found.';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement