Javascript 通过单击定位点显示和隐藏两个图标

Javascript 通过单击定位点显示和隐藏两个图标,javascript,jquery,css,toggle,Javascript,Jquery,Css,Toggle,可以通过单击锚来显示和隐藏两个图标??我有一个基础手风琴,我需要当我点击标签(他们是锚)图标显示消失,反之亦然。我不知道为什么浏览器控制台告诉我'addEventListener'为null,因为元素existan是一个锚点。我想用javascript来实现,但如果不可能,我将使用Jquery。这就是我尝试过但没有成功的方法 <dd class="accordion-navigation"> <a href="#panel1a" class="tab-table" role

可以通过单击锚来显示和隐藏两个图标??我有一个基础手风琴,我需要当我点击标签(他们是锚)图标显示消失,反之亦然。我不知道为什么浏览器控制台告诉我'addEventListener'为null,因为元素existan是一个锚点。我想用javascript来实现,但如果不可能,我将使用Jquery。这就是我尝试过但没有成功的方法

<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>
这是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>

函数切换(){
var arrowTabDown=document.getElementById(“首先隐藏箭头内容”);
var arrowTabUp=document.getElementById(“首先显示箭头内容”);
如果(箭头TabDown.style[“显示”]=“无”){
箭头选项卡。样式[“显示”]=“块”;
arrowTabUp.style[“display”]=“none”;
}否则{
箭头选项卡。样式[“显示”]=“无”;
arrowTabUp.style[“display”]=“block”;
}
};
document.getElementById(“第一个选项卡手风琴”).addEventListener(“单击”,切换,错误);
首先:
您有两个ID用于
#第一个选项卡accordion
,然后您应该在加载标记后运行脚本,这样就可以工作了:

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

函数切换(){
var arrowTabDown=document.getElementById(“首先隐藏箭头内容”);
var arrowTabUp=document.getElementById(“首先显示箭头内容”);
如果(箭头TabDown.style[“显示”]=“无”){
箭头选项卡。样式[“显示”]=“块”;
arrowTabUp.style[“display”]=“none”;
}否则{
箭头选项卡。样式[“显示”]=“无”;
arrowTabUp.style[“display”]=“block”;
}
};
document.getElementById(“第一个选项卡手风琴”).addEventListener(“单击”,切换,错误);
首先:
您有两个ID用于
#第一个选项卡accordion
,然后您应该在加载标记后运行脚本,这样就可以工作了:

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

函数切换(){
var arrowTabDown=document.getElementById(“首先隐藏箭头内容”);
var arrowTabUp=document.getElementById(“首先显示箭头内容”);
如果(箭头TabDown.style[“显示”]=“无”){
箭头选项卡。样式[“显示”]=“块”;
arrowTabUp.style[“display”]=“none”;
}否则{
箭头选项卡。样式[“显示”]=“无”;
arrowTabUp.style[“display”]=“block”;
}
};
document.getElementById(“第一个选项卡手风琴”).addEventListener(“单击”,切换,错误);
首先:
您有两个ID用于
#第一个选项卡accordion
,然后您应该在加载标记后运行脚本,这样就可以工作了:

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

函数切换(){
var arrowTabDown=document.getElementById(“首先隐藏箭头内容”);
var arrowTabUp=document.getElementById(“首先显示箭头内容”);
如果(箭头TabDown.style[“显示”]=“无”){
箭头选项卡。样式[“显示”]=“块”;
arrowTabUp.style[“display”]=“none”;
}否则{
箭头选项卡。样式[“显示”]=“无”;
arrowTabUp.style[“display”]=“block”;
}
};
document.getElementById(“第一个选项卡手风琴”).addEventListener(“单击”,切换,错误);
首先:
您有两个ID用于
#第一个选项卡accordion
,然后您应该在加载标记后运行脚本,这样就可以工作了:

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

函数切换(){
var arrowTabDown=document.getElementById(“首先隐藏箭头内容”);
var arrowTabUp=document.getElementById(“首先显示箭头内容”);
如果(箭头TabDown.style[“显示”]=“无”){
箭头选项卡。样式[“显示”]=“块”;
arrowTabUp.style[“display”]=“none”;
}否则{
箭头选项卡。样式[“显示”]=“无”;
arrowTabUp.style[“display”]=“block”;
}
};
document.getElementById(“第一个选项卡手风琴”).addEventListener(“单击”,切换,错误);

我注意到您的锚标记有两个ID属性。一旦我删除了第二个ID属性(“panel1a标题”),代码对我来说就运行良好


我注意到您的锚标记有两个ID属性。一旦我删除了第二个ID属性(“panel1a标题”),代码对我来说就运行良好


我注意到您的锚标记有两个ID属性。一旦我删除了第二个ID属性(“panel1a标题”),代码对我来说就运行良好


我注意到您的锚标记有两个ID属性。一旦我删除了第二个ID属性(“panel1a标题”),代码对我来说就运行良好



double id代表你的链接(a),你的代码有效double id代表你的链接(a),你的代码有效double id代表你的链接(a),你的代码有效double id代表你的链接(a),你的代码有效Wow真是个错误……对不起,我没注意到。下次我会仔细检查的。谢谢,这是一个多么大的错误……对不起,我没注意到。下次我会仔细检查的。谢谢,这是一个多么大的错误……对不起,我没注意到。下次我会仔细检查的。谢谢,这是一个多么大的错误……对不起,我没注意到。下次我会仔细检查的。谢谢,愚蠢的错误。我没有注意到。谢谢,是的,愚蠢的错误。我没有注意到。谢谢,是的,愚蠢的错误。我没有注意到。谢谢,是的,愚蠢的错误。我没有注意到。谢谢