Create Elements dynamically in Javascript - DOM Manipulation Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ธ.ค. 2024

ความคิดเห็น • 14

  • @Soulcode-k
    @Soulcode-k 3 หลายเดือนก่อน +1

    No one could have explained it better Thank you so much

  • @BhanuPratapSingh-c1n
    @BhanuPratapSingh-c1n ปีที่แล้ว +3

    A simple task can be given to all learners, such as creating a to-do list as follows:
    A heading, an empty tag, an along with a to add an element, and a reset to remove all list items
    I have created it, and it's surprising to see that you already covered all the things that will be needed to create it except getting value from the input field. For it, I used the `.value` property on the input element. 👍🚀

    • @AnkitKumar-pk8tk
      @AnkitKumar-pk8tk 10 หลายเดือนก่อน +1

      Yes I have made simple one


      Document


      Enter your List


      Click to Add!

      const but = document.getElementById("button-click")
      const cont = document.getElementById("container")
      const count = 1
      // console.log(but)
      but.addEventListener("click",()=>{

      const val = document.getElementById("input-id")
      console.log(val.value)
      const ele = document.createElement("h1")
      ele.innerHTML = count +". "+ val.value
      cont.appendChild(ele)
      count++
      val.value = ""

      })
      Feel free to use it

    • @prajwalm.s7976
      @prajwalm.s7976 7 หลายเดือนก่อน

      @@AnkitKumar-pk8tk everything is great, just make the count variable as let instead of const.

  • @muskanramchandani7642
    @muskanramchandani7642 ปีที่แล้ว +2

    Very informative 👍

  • @riteshrudraksha3599
    @riteshrudraksha3599 2 ปีที่แล้ว +2

    Keep up the good work ...

  • @CommonAsian-b2z
    @CommonAsian-b2z 2 วันที่ผ่านมา

    Thank you buddy.

  • @beekei_patel
    @beekei_patel ปีที่แล้ว +1

    How can we save the entire file after dynamic manipulation so that if I reload all the changes like added elements should be visible I mean it shouldn't be deleted on reload of index.html. As I have taken it up it deleted every changes and file was undo as previous. ??
    Sorry for question goes lengthy 😂

    • @piyushgargdev
      @piyushgargdev  ปีที่แล้ว

      You can save the data in local storage or DB and re-render all dom on page load.

  • @googlebaba4045
    @googlebaba4045 ปีที่แล้ว

    thanks you sir

  • @ARSHADKHAN-hc6pb
    @ARSHADKHAN-hc6pb 2 ปีที่แล้ว +1

    Bhai ek issue hota hai dynamically created elements ke sath.
    Events kam nahi karte hai uspe.
    How do we handle it?

    • @piyushgargdev
      @piyushgargdev  2 ปีที่แล้ว +2

      I’ll add it to upcoming videos
      Thanks

    • @ARSHADKHAN-hc6pb
      @ARSHADKHAN-hc6pb 2 ปีที่แล้ว +1

      @@piyushgargdev thank you to bhai ❤️

    • @aer0449
      @aer0449 ปีที่แล้ว +1

      Karte hai bro .... Either aap loops ke through run karo ya fir ID's ko target karke