English 中文(简体)
当我只想一个人时,变换活动手ler就增加了两块 d子。
原标题:Mouseover event handler brings up both divs when I want only one

我正试图为一种情况做一次变换活动,即当你 mo忙时,情况就会.。 当我进行 mo忙时,当我只想一时,它会把两块东西 separate成一片。 这里是我的法典。 第一部分是 mo。 第二是停用。

$( .portfolio img ).mouseover(function(){
    $(this).css( cursor ,  pointer );
    $(this).parent().find( img:first ).stop().animate({opacity:1}, 800, function() {
          $("div.folio").animate({ height:  +=25px , top:  -=24px  }, 100, function() {
                $("div.folio span").animate({ opacity: 1 }, 500);
          });
    });
});

$( .img_grayscale ).mouseout(function(){
       $(this).stop().animate({opacity:0}, 800, function() {
            $("div.folio span").animate({ opacity: 0 }, 500, function() {
                $("div.folio").animate({ height:  -=25px , top:  +=24px  }, 100);
                $("div.folio").css( top ,  -9px );
            });
        });
}); 

        <div class="portfolio">
            <h2>The Portfolio</h2>
            <p class="slideTwo">Check out some of our recent projects.</p>
            <ul>
                <li><img src="portfolioOne.jpg"></img><div class="folio"><span>thesite.com</span></div></li>
                <li><img src="portfolioOne.jpg"></img><div class="folio"><span>mysite.com</span></div></li>
            </ul>
        </div>
问题回答

采用j Query s $("div.folio”),将全部四分之三的“组合”交回。 由于你看到这两种图像的这种估计,而不是仅仅看到你所传播的图像,因此我假定,他们两人在他们想要的iv子上都有同一类。 仅为了结对,在选择 j时,你就更具体。 包括四舍五入到牙齿的路上的费用,通常都是用的,但我可以不使用相应的超文本就告诉你确切的代码。

你们需要取消泡沫活动,把“false”从你的活动手里退回。

$( .portfolio img ).mouseover(function(){
    // Your logic here...
    return false;
});

我对此有两点关切,这些问题可能或可能不会因你所显示的其他情况而产生问题。

  • You re doing $(this).parent().find( img:first ) inside of a jQuery onmouseover function where $(this) should already be representing the img that you care about. Did you find that was necessary for some reason?
  • You could be more specific in your selector. Try doing $(".portfolio>ul>li>img")
  • img_grayscale is only mentioned once in your markup in your question so I m not sure how that class gets applied but I m assuming it does.
  • You could just add the class portfolio (or some unique identifier) to your images directly and probably have an easier time figuring out exactly why it isn t working as you expect. Then your mouseover selector could just be $(".specialClass")

你一定要尝试张贴一个jsfiddle.net;你可以借用网络上的任何两个图像进行测试。

顺便提一下。 我不得不通过以下法典来从根本上改变OM。 我提到了这个形象,然后,我去亲人谈谈我四分五裂的OM的下一个组成部分。 然后,我去该目标的孩子去了。 我基本上在停用上做了同样的事。

            $( .portfolio img ).mouseover(function(){
                $(this).css( cursor ,  pointer );
                $(this).parent().find( img:first ).stop().animate({opacity:1}, 800, function() {
                    $(this).parent().next().animate({ height:  +=25px  }, 100, function() {
                        $(this).children().animate({ opacity: 1 }, 100);
                    });
                });
            });

            $( .img_grayscale ).mouseout(function(){
                $(this).stop().animate({opacity:0}, 800, function() {
                        $(this).parent().next().children().animate({ opacity: 0 }, 100, function() {
                            $(this).parent().animate({height:  -=25px  }, 100);
                    });
                });
            }); 




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签