It would be possible show and hide two icons by clicking an anchor?? I have a Foundation Accordion and I need that when I click on the tabs (They are anchors) the icon is displayed to disappear and viceversa. I don't know why the browser console tells me 'addEventListener' of null, because the element exist an is an anchor. I would like to do it with javascript but if is not possible I'll use Jquery. This is what I've tried without succes.
<dd class="accordion-navigation">
<a href="#panel1a" class="tab-table" role="tab" id="panel1a-heading" aria-controls="panel1a" id="first-tab-accordion">Subastas Activas
<i class="fa fa-chevron-down styled-tab-icon arrow-content-hidden" id="arrow-content-hidden-first"></i>
<i class="fa fa-chevron-up styled-tab-icon arrow-content-shown" id="arrow-content-shown-first"></i>
</a>
// More stuff...
</dd>
This is the css
.arrow-content-hidden {
}
.arrow-content-shown {
display: none;
}
This is the js
<script>
function toggle() {
var arrowTabDown = document.getElementById("arrow-content-hidden-first");
var arrowTabUp = document.getElementById("arrow-content-shown-first");
if (arrowTabDown.style["display"] == 'none') {
arrowTabDown.style["display"] = 'block';
arrowTabUp.style["display"] = 'none';
} else {
arrowTabDown.style["display"] = 'none';
arrowTabUp.style["display"] = 'block';
}
};
document.getElementById("first-tab-accordion").addEventListener("click", toggle, false);
</script>