Javascript not working in edge/firefox and Safari but on chrome it works
-
hello I had a problem but I can’t figure out where it comes from, I had javascript codes on my site developed with wordpress that were used to make the “menu filter element” work, I already inserted it about three months ago and everything worked, today I realized that the menu no longer works when I click on the buttons it does not change the filters as if the javascript code were no longer there, the strange thing is that it works on chrome and on all other browsers the problem, but I repeat it worked before from all sides not how this sudden problem happened. Solutions? I am attaching the code
<script> filterSelection("all") function filterSelection(c) { var x, i; x = document.getElementsByClassName("filterDiv"); if (c == "all") c = ""; // Add the "show" class (display:block) to the filtered elements, and remove the "show" class from the elements that are not selected for (i = 0; i < x.length; i++) { w3RemoveClass(x[i], "show"); if (x[i].className.indexOf(c) > -1) w3AddClass(x[i], "show"); } } // Show filtered elements function w3AddClass(element, name) { var i, arr1, arr2; arr1 = element.className.split(" "); arr2 = name.split(" "); for (i = 0; i < arr2.length; i++) { if (arr1.indexOf(arr2[i]) == -1) { element.className += " " + arr2[i]; } } } // Hide elements that are not selected function w3RemoveClass(element, name) { var i, arr1, arr2; arr1 = element.className.split(" "); arr2 = name.split(" "); for (i = 0; i < arr2.length; i++) { while (arr1.indexOf(arr2[i]) > -1) { arr1.splice(arr1.indexOf(arr2[i]), 1); } } element.className = arr1.join(" "); } // Add active class to the current control button (highlight it) var btnContainer = document.getElementById("myBtnContainer"); var btns = btnContainer.getElementsByClassName("btn"); for (var i = 0; i < btns.length; i++) { btns[i].addEventListener("click", function() { var current = document.getElementsByClassName("active"); current[0].className = current[0].className.replace(" active", ""); this.className += " active"; }); } </script>
La pagina su cui ho bisogno di aiuto: [devi essere connesso per vedere il link]
- Il topic ‘Javascript not working in edge/firefox and Safari but on chrome it works’ è chiuso a nuove risposte.