我想将此功能从鼠标悬停和鼠标悬停转换为单击事件以下代码。如何将鼠标悬停和鼠标悬停功能转换为单击事件
var IdAry=['slide2','slide3','slide4','slide5','slide8','slide9','slide12','slide13','slide14','slide15','slide16'];
window.onload=function() {
for (var zxc0=0;zxc0<IdAry.length;zxc0++){
var el=document.getElementById(IdAry[zxc0]);
if (el){
el.onmouseover=function() {
changeText(this,'hide','show')
}
el.onmouseout=function() {
changeText(this,'show','hide');
}
}
}
}
function changeText(obj,cl1,cl2) {
obj.getElementsByTagName('SPAN')[0].className=cl1;
obj.getElementsByTagName('SPAN')[1].className=cl2;
}
以下是HTML部分
<div id="graphics">
<img src="images/circle-bg.jpg" alt="" class="circleBg"/>
<div class="row1">
<a href="#" id="slide1" id="selectedSlide">
<span id="span1"></span>
<span class="hide"></span>
</a>
<a href="#" id="slide2">
<span id="span1"></span>
<span class="hide">At this stage, we sit down together and discuss your life goals and begin to develop a plan for funding them. Without knowing where you want to go, we can't help get you there! This is the time to ask a lot of questions and get to know each other. </span>
</a>
<a href="#" id="slide3">
<span id="span1"></span>
<span class="hide">We need to know your current income and expenses in order to gain a better understanding of resources that can be applied toward your financial goals. We also determine the appropriate size of your emergency fund. </span>
</a>
<a href="#" id="slide4">
<span id="span1"></span>
<span class="hide"></span>
</a>
</div>
</div>
目前在ID滑件,滑件,滑件3 ..等用户鼠标悬停定位标记它添加类节目,以一个跨度,并隐藏到其他反之亦然在mouseout中。
因此,如果可以将此功能转换为单击事件而不是鼠标悬停和鼠标悬停。
在此先感谢
您将此标记为jQuery,但您的代码是纯JavaScript。你想要一个jQuery解决方案还是纯JS的等价物?另外,你到目前为止尝试过什么? – rcdmk 2012-08-08 12:11:38