我有一个div切换点击按钮,我也设置为切换...我想允许用户通过单击相同的切换按钮或通过单击显示中的关闭选项来关闭div DIV。问题是,如果用户选择使用关闭选项,则切换按钮会反转,因为它未设置为使用关闭选项切换。
<!-- Toggle Button -->
<script type="text/javascript">
if(window.addEventListener){
window.addEventListener('load',multiImageSwap,false);
}
else {
if(window.attachEvent){
window.attachEvent('onload',multiImageSwap);
}
}
function multiImageSwap(){
test=true;
document.getElementById('pic').onmouseover=function() {
if(test==true) {
this.src='images/SN_Page_10_23_Possible_19A.png';
}
else {
this.src='images/SN_Page_10_23_Possible_19B.png';
}
}
document.getElementById('pic').onmouseout=function() {
if(test==true) {
this.src='images/SN_Page_10_23_Possible_19A.png';
}
else {
this.src='images/SN_Page_10_23_Possible_19B.png';
}
}
document.getElementById('pic').onclick=function() {
if(test==true) {
this.src='images/SN_Page_10_23_Possible_19B.png';
test=false;
}
else {
this.src='images/SN_Page_10_23_Possible_19A.png';
test=true;
}
}
}
</script>
<!-- Toggle Reading -->
<script type="text/javascript">
function toggleDiv(divId) {
$("#"+divId).toggle();
}
</script>