English 中文(简体)
只有在处于特定地位的情况下,才能使遗骨结扎起来?
原标题:How to animate a div only if it s at a specific position?

是否有通向(滑坡)<代码>div的途径;例如,如果在网页上某个位置上 /strong>?

For example, there are four divs that all have the same class .ALLCONTENT, but when a button (which has class .BUTTONS) is clicked only the div that s at 30 px from the top will animate downwards, the rest will remain in the same place.

从根本上说,如果这种四分五裂的局面已经进一步滑坡,就将四分五舍五入到某个位置;问题一现在就存在。

$(".BUTTONS").click(function(){
    $(".ALLCONTENT").animate({"top":"+=558px"}, 250,  linear );
});
最佳回答

use

if($(".ALLCONTENT").offset().top === 20) {
    //Do something
}

如果你想将其绝对立场查到文件/机构

以及

if($(".ALLCONTENT").css("top") === "20px") {
    //Do something
}

if($(".ALLCONTENT").position().top === 20) {
    //Do something
}

如果你想要检查其相对立场,

问题回答

如果无法分配假肢(尽管我无法形象),则使用:

if($(".ALLCONTENT").css("top") == "20px") {
//Do something

}
$(".BUTTONS").click(function(){  
    $(".ALLCONTENT").each(function(i){
        if($(this).css("top")=="30px"){
            $(this).animate({"top":"558px"}, 250, "linear");
        }
    })
});




相关问题
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.