codedamn

Change HTML attributes with JavaScript

Created by Codedamn about a year ago

0

No description provided

18 Comments

    -1

    Excellent video👌

    @hemantmehta29

    HemantMehta29

    @hemantmehta29

    -1

    it is working now, but I have to reload the browser. if we try to change from one video to another constantly, the video stops loading only the name of the clicked video displays in the video section and the previous video continues. don't know why this is happening.

    @kiranrai

    Kiran rai

    @kiranrai

    1

    This content was deleted by the author

    @jinxonion

    Jinay Gada

    @jinxonion

    3

    const ul=document.querySelector("#listItem") increment.addEventListener("click", function(){ let li=document.createElement("li") ul.append(li) li.append(counter) }) decrement.addEventListener("click", function(){ ul.removeChild(ul.lastChild);

    })

    @abhis3kh

    Abhisekh

    @abhis3kh

    1

    why square-brackets around data-counter? and why is it a + sign before and after the counter value variable?

    @cheung

    Kitt Cheung

    @cheung

    1

    Learned a lot of things from you but the thing which I remember is "That's pretty much for it. I'm gonna see you in the next video really soon."

    4

    Learned a lot of things from you but the thing which I remember is "That's pretty much for it. I'm gonna see you in the next video soon." Excellent video👌

    2

    bro u r not explaining things correctly. You are saying this is that and thats all .Seriously the course went from beginner level to hard level

    @shinoo

    Shinoy

    @shinoo

    6

    Used to be simple at the beginning then you suddenly changed to advanced seriously we cant understand mehul

    @badree69

    Badrinath Shivaling

    @badree69

    -1

    4.45k views till 21-1-23

    1

    exponential difficulty increase identified. :_ )

    3

    cant understand, i think the explanation is not good enough..should be explaining it more deeply

    @tagetapang

    tage tapang

    @tagetapang

    0

    DOM part of the course is very difficult to understand in such fast way

    @ashishvalvi

    Ashish valvi

    @ashishvalvi

    1

    not understand this perfectly. Please try to teach as beginner friendly

    @mustanrath7

    Mustan Rath

    @mustanrath7

    0

    // IMPROVED VERSION

    const count = document.querySelector(".count"); let incrementer = document.querySelector('#incrementer'); let decrementer = document.querySelector('#decrementer'); let counter = 0 const unorderdist = document.getElementById('list-type')

    function increment() { counter++ count.innerText = counter

    // Inner HTMl to get sentence
    
    if (counter > 0) {
        const li = document.createElement('li')
        li.innerHTML = "<b>Sentence</b> " + counter;
        unorderdlist.appendChild(li)
        //? setAttribute
        li.setAttribute('data-tag', counter);
    }
    else {
        const removal = unorderdlist.querySelector('[data-tag="' + counter + '"]')
        // ul li[data-tag="food"]{
        //     color: blue;
        // }
        removal.remove()
    

    //? "'+counter+'" meant that we are passing a number like string in "food", to pass a number we can't do it directly and hear in data-tag we have to use double quotes in outer part so we used first single quotes and than we write the variable

    }
    

    }

    function decrement() {

    if (counter <= 0) {
        const li = document.createElement('li')
        li.innerHTML = "<b>Sentence</b> " + counter;
        li.setAttribute('data-tag', counter);
        unorderdlist.appendChild(li)
    }
    else {
        const removal = unorderdlist.querySelector('[data-tag="' + counter + '"]')
        // ul li[data-tag="food"]{
        //     color: blue;
        // }
        removal.remove()
    }
    counter--
    count.innerText = counter
    

    }

    incrementer.addEventListener('click', increment) decrementer.addEventListener('click', decrement)

    @krushalpagda

    Krushal Pagda

    @krushalpagda

show more answers
Your comment