我有 2 个功能可以做同样的事情。一种有效,一种无效。
function showHideRedrawAttendanceAvg(chart, dataType)
{
$("#attendanceCount").addClass("hide");
$("#attendanceAvg").removeClass("hide");
redrawAttendance(chart, dataType);//Parameters are defined
}
function redrawAttendance(chart, dataType) //Parameters are passed and are defined
{
//Some logic
}
//I tried change the parameter name several times to make sure it was unique
function showHideRedrawAttendanceCount(agagfadfg)
{
$("#attendanceAvg").addClass("hide");
$("#attendanceCount").removeClass("hide");
redrawAttendanceTree(agagfadfg);//Parameter is defined
}
function redrawAttendanceTree(agagfadfg)//Parameter becomes undefined
{
//Some logic
}
我不知道为什么这两个函数的行为不同。我什至从文件中删除了我所有的 javascript,只留下了 showHideRedrawAttendanceCount 和 redrawAttendanceCount 函数,但它仍然不起作用。
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a href="#">Attendance Average</a>
<ul class="dropdown-menu">
<li><a data-toggle="tab" href="#attendance" onclick="showHideRedrawAttendanceAvg(attendance, 'Weekly')">Weekly</a></li>
<li><a data-toggle="tab" href="#attendance" onclick="showHideRedrawAttendanceAvg(attendance, 'Monthly')">Monthly</a></li>
<li><a data-toggle="tab" href="#attendance" onclick="showHideRedrawAttendanceAvg(attendance, 'Quarterly')">Quarterly</a></li>
<li><a data-toggle="tab" href="#attendance" onclick="showHideRedrawAttendanceAvg(attendance, 'Yearly')">Yearly</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="#">Attendance Total</a>
<ul class="dropdown-menu">
<li><a data-toggle="tab" href="#attendance" onclick="">Weekly</a></li>
<li><a data-toggle="tab" href="#attendance" onclick="showHideRedrawAttendanceCount('Monthly')">Monthly</a></li>
<li><a data-toggle="tab" href="#attendance" onclick="showHideRedrawAttendanceCount('Quarterly')">Quarterly</a></li>
<li><a data-toggle="tab" href="#attendance" onclick="showHideRedrawAttendanceCount('Yearly')">Yearly</a></li>
</ul>
</li>
</ul>