Widget:ResultCounter: Difference between revisions

From Rinchen Terdzö
((by SublimeText.Mediawiker))
 
((by SublimeText.Mediawiker))
 
(5 intermediate revisions by the same user not shown)
Line 2: Line 2:


var results = document.getElementsByClassName("result");
var results = document.getElementsByClassName("result");
for (var i = 0; i < results.length; i++) {
addCounter(results.item(i),i)
}


results.forEach(addCounter)
function addCounter(element,index) {
 
function addCounter(element) {
let index = element.indexOf();
let counterDiv = element.querySelectorAll(":scope > div#resultIndex");
let counterDiv = element.querySelectorAll(":scope > div#resultIndex");
counterDiv.innerHTML = index;
counterDiv.innerHTML = index;

Latest revision as of 07:22, 5 April 2024

<script>

var results = document.getElementsByClassName("result"); for (var i = 0; i < results.length; i++) { addCounter(results.item(i),i) }

function addCounter(element,index) { let counterDiv = element.querySelectorAll(":scope > div#resultIndex"); counterDiv.innerHTML = index; }

</script>