Click here to Skip to main content
15,893,904 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
so i got this functions that's supposed to remove classes from elements,and set their innterHTML to nothing,however i got a condition before that stats that if that elment contains a certain class skip the iteration,
this does preserve the class and doesn't remove it so this part does work correctly, however it still overwrites the innerHTML content to nothing , no idea why?

the function:
function removeHints(board, i, j) {
    var elms = getHint(board, i, j)
    for (var i = 0; i < elms.length; i++) {
        if (elms[i].classList.contains('show')) {
            continue
        }
        else {
            elms[i].classList.remove('hint')
            elms[i].innerHTML = ''
        }
    }
}


What I have tried:

i have no idea how to continue
Posted
Updated 24-Jan-20 9:59am

1 solution

You can get rid of the continue part since there is nothing else to do in that case anyway:
JavaScript
function removeHints(board, i, j) {
    var elms = getHint(board, i, j);
    for (var i = 0; i < elms.length; i++) {
        if (!elms[i].classList.contains('show')) {
            elms[i].classList.remove('hint');
            elms[i].innerHTML = '';
        }
    }
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900