The elements I selected with querySelectorAll come 2 times in the for loop

https://jsfiddle.net/df1Lhqb7/ I am trying to write a todo application and the completed part button works normally, but when I add a new element, it works as if the button is clicked 2 times. I am writing a todo app and by default it works when I press complete on the items in the list. But… Read More The elements I selected with querySelectorAll come 2 times in the for loop

How to split a string into substrings that are sandwiched or separated by the same letter in JavaScript?

I have this string: const str = "abbbaba"; I am looking for a way to split this string in groups of sandwiched letters, or all remaining letters. Examples My string should be split into this: ["abbba", "ba"] Where "abbba" is the first substring because it starts and ends with an "a". The last substring starts… Read More How to split a string into substrings that are sandwiched or separated by the same letter in JavaScript?

click event doesn't bubble up on image thats nested in

when i click on the image it doesnt bubble up to the parent which does have the "questions" class and make the if condition true, isnt it supposed to work that way? document.addEventListener(‘click’, function(event){ if(event.target.classList.contains(‘questions’)){ const answers = event.target.nextElementSibling; answers.style.display = answers.style.display === “block”? “none” : “block”; } else{ document.querySelectorAll(‘dd’).forEach((dd)=>dd.style.display= “none”) } }); <div class=”faq-item”>… Read More click event doesn't bubble up on image thats nested in

Adding class to A tag after onclick

I have the below code <li class="nav-item"> <a class="nav-link" href="#" onclick="showNotConfirmedDiv()"> <span data-feather="file-text"></span> Not Confirmed<span class="badge updateBadge">1</span> <!– TODO ONLY SHOW BADGE IF THERE IS A NUMBER!!!!! –> </a> </li> I want the add active to the class for the anchor tag when I hit the li.a tag <li class="nav-item"> <a class="nav-link active" href="#" onclick="showNotConfirmedDiv()">… Read More Adding class to A tag after onclick

How to delete data by mask in Javascript using .replace or something else?

I’m getting data in the form of date and time: Monday Jan 23 10:14:27 2024 How in Javascript using .replace to remove everything except time without seconds: 10:14 . Please tell me, because I am already lost in these regular expressions. Thank you all. >Solution : Use String.prototype.match const reg = /\d{2}:\d{2}/ const str =… Read More How to delete data by mask in Javascript using .replace or something else?