Skip to content

How can i get a index value of a div just clicking on it?

I’m trying to change the class of an specific div that i click, using this: This code above works well, but only in all divs at the same time, not with only that I’ve clicked Answer There is no need for ids and you should not use inline event attributes like onclick and instead separate your JavaS…

Perform an action after a promise.then callback

I’m trying to encapsulate some intialization / clean up code in a single Promise. What I want if to execute some code, execute the then and then execute some more code. This is what I came up with: which gives me the following output in the terminal: All good so far. However, when we make the callback a…

livewire dispatchBrowserEvent is not triggering alert

I have a livewire component which has an update() function to update the component when it changes. The update() function is called and updates the item in the database as required. At the end of this function i run a dispatchBrowserEvent() to confirm the update but the corresponding function in my js file is…

Switch paragraphs using inner HTML in JS

I am trying to switch two paragraphs after clicking the button but I am stuck. Is there any way how to do this using inner HTML without using IF or boolean? I tried this code but it doesn’t work. Thanks Answer Why don’t you use querySelector in place of using querySelectorAll and choose the first …