javascript - Show and hide two icons by clicking an anchor -


this question has answer here:

it possible show , hide 2 icons clicking anchor?? have foundation accordion , need when click on tabs (they anchors) icon displayed disappear , viceversa. don't know why browser console tells me 'addeventlistener' of null, because element exist an anchor. javascript if not possible i'll use jquery. 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 css

.arrow-content-hidden {  }  .arrow-content-shown {   display: none; } 

this 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> 

at first :
have 2 ids #first-tab-accordion , should run script after tags loaded work :

<dd class="accordion-navigation">   <a href="#panel1a" class="tab-table" role="tab" 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> </dd> <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> 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -