的代码$("#adminLink")
工作得很好,但$("#itemLink")
没有。我已经尝试了我能想到的一切。我想我需要一双新鲜的眼睛。我要做的就是在单击元素时更改这两个 img 的 src 。
代码:
$(document).ready(function () {
HidelemArr = new Array();
HidelemArr[0] = "addItem";
HidelemArr[1] = "addAdmin";
//* hide presets
$.each(HidelemArr, function () {
$("#" + this).hide();
})
//*
$("#adminLink").click(function () {
var chld = $("#menuIMG");
var vis = (document.getElementById(HidelemArr[1]).style.display == 'block') ? 1 : 0;
changeDisplay(HidelemArr[1], vis, chld);
});
$("#itemLink").click(function () {
var chld = $("#Mitemimg");
var vis = (document.getElementById(HidelemArr[0]).style.display == 'block') ? 1 : 0;
changeDisplay(HidelemArr[0], vis, chld);
});
});
function changeDisplay(id, vis, chld) {
$.each(HidelemArr, function () {
if ((this == id) && (vis == 0)) {
chld.attr("src", "images/icon_sync.gif");
$("#" + this).slideDown('slow', function () {});
} else {
chld.attr("src", "images/icon_trace.gif");
$("#" + this).slideUp('slow', function () {});
}
})
}
html:
<ul>
<li class="header">Quick Access:</li>
<li ><span id="itemLink">
<a >Add Item</a>
<img id="Mitemimg" class="qaimg" src="images/icon_trace.gif"></span></li>
<li ><span id="adminLink">
<a >Add Administrator</a>
<img id="menuIMG" class="qaimg" src="images/icon_trace.gif"></span></li>
</ul>
</div>
<div id="main">
<h1>Actions Required:</h1>
<div id="forms">
<table class="linkForm" id="addItem">
<?php require_once 'additemform.php'; ?>
</table>
<table class="linkForm" id="addAdmin">
<?php require_once 'addAdminForm.php'; ?>
</table>
</div>
</div>