Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to make a
  • when clicked on a button js
  • function AddLi(str)
    {
        var li = document.createElement('li');
        li.appendChild(document.createTextNode(str))
        li.innerHTML += ' <button onclick="this.parentNode.remove()">-</button>';
        document.getElementById("out").appendChild(li);
    }
    Comment

    how to make a
  • when clicked on a button js
  • (function () {
      document.querySelector('#add').addEventListener('click', function () {
        let input = document.querySelector('#text');
        let list = document.querySelector('#list'); 
        
        let item = document.createElement('li'); // create li node
        let itemText = document.createTextNode(input.value); // create text node
        
        item.appendChild(itemText); // append text node to li node
        list.appendChild(item); // append li node to list
        
        input.value = ""; // clear input
      });
    })();
    Comment

    how to make a
  • when clicked on a button js
  • <div>
      <input id="text" type="text" />
      <button id="add">Add</button>
    </div>
    
    <ul id="list">
      <li>example item</li>
    </ul>
    Comment

    how to make a
  • when clicked on a button js
  • <form>
        <input type="text" name="userinput">
        <input type="button" value="Add LI" onclick="AddLi(userinput.value)">
    </form> 
    <span id="out"/>
    Comment

    PREVIOUS NEXT
    Code Example
    Javascript :: javascript paragraph class 
    Javascript :: javascript perms 
    Javascript :: select triggers mouseleave 
    Javascript :: ubicar escrol en el final jquey 
    Javascript :: rejectUnauthorized 
    Javascript :: how to make messaging website with firebase javascript 
    Javascript :: Arr::flatten() The Arr::flatten method flattens a multi-dimensional array into a single level array: 
    Javascript :: js file not found in laravel on live laravel project 
    Javascript :: angular material slide effect button click 
    Javascript :: how to change the backgroung of one button when click the other one 
    Javascript :: trie node pseudocode 
    Javascript :: vue unit tests form submit 
    Javascript :: unable to get local issuer certificate npm 
    Javascript :: change to kebabcase in javascript 
    Javascript :: whatsapp images not showing in meta tags 
    Javascript :: only integer allowed javascript 
    Javascript :: which element occours when a DOM element recieve the coursor 
    Javascript :: how to get the index of an object inside of a map js 
    Javascript :: multi level route static file not found issue in express 
    Javascript :: python faker json 
    Javascript :: prop callback that changes parent state result in infinite render react js 
    Javascript :: react pass object to state 
    Javascript :: javascript interview quetions 
    Javascript :: js deconstruct rename 
    Javascript :: how to make your own version of filter method 
    Javascript :: JavaScript code to convert amount in words 
    Javascript :: joining two array 
    Javascript :: how to use file js 
    Javascript :: react button onclick components refined #1 
    Javascript :: Both This Have The Same Value 
    ADD CONTENT
    Topic
    Content
    Source link
    Name
    3+3 =