Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to make a delete button in javascript

<!DOCTYPE html>
<html>
<body>

Name: <input type="text" id="myText" value="">
<br/>
<br/>
Age: <input type="number" name="age">

<button onclick="myFunction()">Try it</button>

<script>

function myFunction() {
    var input = document.getElementsByTagName('input')[0].value;
    var agenum = document.getElementsByTagName('input')[1].value;
    var div = document.createElement('div');
    div.style.border = '2px solid red';
    div.style.padding = '10px';
    div.style.display = 'block';
    document.body.appendChild(div);
    var output = 'Name: ' + input + '<br/>' + 'Age: ' + agenum;
    div.innerHTML = output;
    deleteButton(div);
}

function deleteButton(x) {
    var del = document.createElement('button');
    del.style.textDecoration = 'none';
    del.innerHTML = 'Remove this person?';
    del.style.color = 'white';
    del.style.backgroundColor = 'blue';
    document.body.appendChild(del);
}


</script>

</body>
</html>
Comment

PREVIOUS NEXT
Code Example
Javascript :: first element of array js 
Javascript :: How to acces props of a functional component 
Javascript :: how to use the javascript console 
Javascript :: how to create scroll to top button in reactjs example code 
Javascript :: turn string into number javascript 
Javascript :: monngoose find from an array using in 
Javascript :: how to remove an item from an object in javascript 
Javascript :: javascript sort object by value descending 
Javascript :: how to get the last element of an array in javascript 
Javascript :: convert string to a number javascript 
Javascript :: why does array index start from 0 
Javascript :: autofocus is not working in react native 
Javascript :: js flatten 
Javascript :: add role to channel discord.js 
Javascript :: javascript promise methods 
Javascript :: discord message reply 
Javascript :: jquery edit href 
Javascript :: how to clear nodejs terminal in vs code 
Javascript :: javascript remove last word from string 
Javascript :: javascript error null 
Javascript :: select all checkbox in angular 
Javascript :: angular conditional tooltip 
Javascript :: reverse array recursion javascript 
Javascript :: linkedin api v2 get email address 
Javascript :: apoolo uselaxyQuery bypass cache 
Javascript :: javascript regular expression methods 
Javascript :: var s= 
Javascript :: ejs include 
Python :: import beautifulsoup 
Python :: increase figure size in matplotlib 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =