• 10-02-2022, 19:09:37
    #1
    Merhaba arkadaşlar. Javascript dilinde dinamik olarak tuş ekliyorum. Her bir tuşla input'un verilerini almak, alert'e göndermek istiyorum ama yapamadım. Yardımcı olabilir misiniz? Teşekkürler. 🙂 Kodlarım aşağıdadır:

    https://codepen.io/umityildrim/pen/qBVmYpw

  • 10-02-2022, 19:50:00
    #2
    const addInput = () => {
      const wrapper = document.createElement('div');
      const input = document.createElement('input');
      const button = document.createElement('button');
      
      input.placeholder = 'İsim giriniz...';  
      
      button.innerHTML = 'KARŞILA';
      
      button.addEventListener('click', () => {
        alert(`Merhaba ${input.value}`)
      })
      
      wrapper.appendChild(input);
      wrapper.appendChild(button);
      
      document.body.appendChild(wrapper);
    }
    
    const buttonAdd = document.getElementById('ar_in_ts_ekle');
    
    buttonAdd.addEventListener('click', addInput);
    Bu çalışır
  • 10-02-2022, 20:52:30
    #3
    Anathory adlı üyeden alıntı: mesajı görüntüle
    const addInput = () => {
      const wrapper = document.createElement('div');
      const input = document.createElement('input');
      const button = document.createElement('button');
      
      input.placeholder = 'İsim giriniz...';  
      
      button.innerHTML = 'KARŞILA';
      
      button.addEventListener('click', () => {
        alert(`Merhaba ${input.value}`)
      })
      
      wrapper.appendChild(input);
      wrapper.appendChild(button);
      
      document.body.appendChild(wrapper);
    }
    
    const buttonAdd = document.getElementById('ar_in_ts_ekle');
    
    buttonAdd.addEventListener('click', addInput);
    Bu çalışır
    ALLAH razı olsun, çalıştı hocam. 🙂👌 CUMA akşamımız mübarek olsun. 🙂🤲