Welcome, guest! Login / Register - Why register?
Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)

Paste

Pasted as JavaScript by tee ( 6 years ago )
const btnAdd = document.querySelector('.btnAddAdress');
const list = document.querySelector('#book-list ul');

btnAdd.addEventListener('click', function(){
    console.log("work!");
    addElement();
    
})

function addElement(){
 //add
    let newInput = document.createElement('input');
    let btnRemove = document.createElement('button');
    let btnRemoveName = document.createTextNode('Remove');

    btnRemove.appendChild(btnRemoveName); 
    let newLine = document.createElement('br');

    document.body.appendChild(newInput);
    document.body.appendChild(btnRemove);
    document.body.appendChild(newLine);
    //document.body.children.length
    let lengthElement = document.querySelectorAll('input').length;
    console.log(lengthElement);
    function removeElement(){
       

        if(lengthElement == 5){
            console.log("disabled button");
            btnAdd.disabled = true;
        }
        else if(lengthElement <= 4){
            console.log("enable button");
            btnAdd.disabled = false;
            
        }
        else{
            console.log("woo22");
        }
    }
    console.log(document.body.children.length);
    removeElement();    



    let focusWork = newInput.focus();
    newInput.addEventListener('click', function(){
        console.log("p");
        
    })  

 btnRemove.addEventListener('click', function(){
    console.log("hello");
    btnRemove.remove();
    newInput.remove();
    newLine.remove();

})  

}

 

Revise this Paste

Your Name: Code Language: