所以我有一个由div
组成的侧边菜单,其中包含一些文字和一个链接。
当我翻转div
时,我会淡入图像。
当我滚动div
中的标记链接时,它会重复相同的功能并创建另一个淡入同一图像的女巫看起来真正的错误。
如何阻止标签链接重复功能
我尝试在链接滚动时创建一个设置为true的变量,并在淡入方法中创建一个if但是没有成功?
任何想法都会受到赞赏。
$j=jQuery.noConflict();
jQuery(document).ready(function($) {
var num = 0;
var numtot = 4;
var delai = null;
var stop_x=0;
var numCur=0;
var thisIs = 0;
var delayRoll = 0;
var count = null;
var overlink = false;
//on ini
//--//
$j(document).ready(function() {
function start() {
delai=setInterval(test, 5000);
console.log(">> start interval");//>>>>>>>>>>>>>>>>>>>trace;
};
numtot = ($j("#news dl dt").size())-1;
test();
start();
})
function fistImage(){
//if(delayRoll==0){
$j("#news dl dd").fadeOut();
$j("#news dl dt").removeClass('current');
console.log("num on test: " + num);//>>>>>>>>>>>>>>>>>>>trace;
console.log("numCur on test: " + numCur);//>>>>>>>>>>>>>>>>>>>trace;
//console.log("current is"+ );//>>>>>>>>>>>>>>>>>>>trace;
$j("#news dl dt").eq(num).addClass('current');
$j("#news dl dt").eq(num).next('dd').fadeIn(500);
if (num>=numtot) {num = 0;} else {num ++;};
//}
}
//firstImage();
//--//
////////--------//////// NEXT IMAGE METHOD
function nextImage(){
if( overlink == false || overlink == true){
console.log("delayRoll image: " + delayRoll);//>>>>>>>>>>>>>>>>>>>trace;
$j("#news dl dd").fadeOut();
$j("#news dl dt").removeClass('current');
$j(thisIs).addClass('current');
$j(thisIs).next('dd').fadeIn(500);
//stop_x=1;
var new_pos=$j(thisIs).attr('id').substring(4, 5);
new_pos=parseInt(new_pos);
if (numtot==new_pos) {new_pos = 0;}
num = new_pos;
numtot = ($j("#news dl dt").size())-1;
}
}
//--//
function test() {
//console.log("num on test: " + num);//>>>>>>>>>>>>>>>>>>>trace;
if(stop_x==0){
fistImage();
}
if(stop_x==1){
}};
//--//
//--/
delai=setInterval(test, 5000);
//--//
//-- OVERLAY//
$j(".overlay").mouseover(function() {
stop_x=1;
}).mouseout( function (){
stop_x=0;
});
//--//mouseover
$j("#news dl dt").mouseover(function() {
thisIs = $j(this);
stop_x=1;
clearInterval(delai);
nextImage();
delayRoll==2;
})
$j("#news dl dt").mouseout(function() {
stop_x==0;
firstImage();
delayRoll=0;
})
$("#news dl dt a").live("mouseover mouseout", function() {
// alert(this.href);
//return false;
overlink=true;
});
})//close duc ready
//--//
这里是html
<div id="news" class="slideshow">
<dl>
<dt id="pos_1">08/16/11<br /><br />Holy Cross to Welcome Class of 2015 on Aug. 27<br />
<a class="more" href="blog/2011/08/16/holy-cross-to-welcome-class-of-2015-on-aug-27/index.html">See more ></a>
</dt>
<dd>
<div class="overlay">
<p>Holy Cross to Welcome Class of 2015 on Aug. 27 <span class="nav">
<img src="wp-content/themes/marsten/images/ico_more_white.png" width="14" height="14" alt="" />
<div id="disLink"><span><a class="more" href="blog/2011/08/16/holy-cross-to-welcome-class-of-2015-on-aug-27/index.html" >See more ></a></span></div>
</span>
</p>
<div id="boxit"><p class="author">by <a href="blog/2011/08/16/holy-cross-to-welcome-class-of-2015-on-aug-27/index.html"></a>
<a href="blog/author/nmarkant/index.html" title="Posts by Nikolas Markantonatos">Nikolas Markantonatos</a></p></div>
</div>
<img alt="" src="wp-content/uploads/2011/08/gate2.jpg" width="612" height="451" />
</dd>
答案 0 :(得分:0)
在淡入淡出后尝试在悬停期间执行event.stopPropagation
...