亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

javascript - How to slide the screen on the mobile phone to get the distance from the top of a certain element? At the same time, can this value be referenced by other functions?
PHPz
PHPz 2017-05-18 11:02:18
0
2
694

As the title says, what I want to achieve is to slide the mobile phone screen. When an element is a certain value from the top (for example, 200px), click the pop-up button on the screen, and the position of the pop-up layer will be 200px from the top

$(document).ready(function(){
    $('.content_box').bind('touchstart', function(e) {
        var a =$(".article_box").offset().top;
        distance = a;
        console.log(distance);
    });
});
//執(zhí)行函數(shù)
function show_taboo(){
    if(distance>200){
        alert("出現(xiàn)了")//做處理
    }else{
        alert("隱藏")、、處理
}

What I want to achieve is this effect. The value of distance can be obtained, but it cannot be referenced in the show function. Can you please help me?

PHPz
PHPz

學(xué)習(xí)是最好的投資!

reply all(2)
左手右手慢動(dòng)作

The solution found is as follows:
$(document).ready(function(){

         $('.content_box').bind('touchstart', test());
 });

//Define function
function test(){

 return $(".content_box").offset().top;      

}
//Execute function
function show_taboo(){

distance = test();//獲得監(jiān)聽事件的值
if(distance>200){
    alert("出現(xiàn)了")//做處理
}else{
    alert("隱藏") //處理
}

}

小葫蘆
$(document).ready(function(){
                    $('.content_box').bind('touchstart', function(e) {
                    var a = $(".content_box").offset().top;
                    distance = a;
                    console.log(distance)
                    return show_taboo(distance)
                    });
            });
            //執(zhí)行函數(shù)
            function show_taboo(distance){
                if(distance>200){
                    alert("出現(xiàn)了")//做處理
                }else{
                    alert("隱藏") //處理
                }
            }
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template