Well, I'm new using Javascript and I'm having some difficulties. I have a box that has 6 links, this is involved in a dom-repeat, that is, there are many 'boxes' with 6 links inside. I need to check if there is a link within each box, if it has one I can already leave the box visible, but if all are empty or empty box should disappear. Unfortunately I can not think of logic enough to get what I need. Also I'm having difficulty getting the href value.
I tried to create a code, but besides not working, I think I'm thinking badly about how to solve the problem, I seem to lack something to analyze all 6.
Function I created to try to resolve:
function teste(){
var div = document.getElementsByClassName('box');
var links = div.getElementsByTagName('a').href;
if(links == '#'){
div.style.display = 'none'
}
}
I mounted a second function, but it also did not work
function teste2(){
var box = document.getElementsByClassName('box');
var link = box.getElementsByTagName('a').href;
var contar = 0;
for (x = 0; x < 6; x++){
if(link == "#"){
contar++
}
}
if (contar == 6){
box.style.display = 'none'
}
}
HTML base
<div class="box">
<a href="#">A</a>
<a href="#">B</a>
<a href="#">C</a>
<a href="#">D</a>
<a href="#">E</a>
<a href="#">F</a>
</div>