当窗口小于900px时,有没有办法只调用一次函数

时间:2016-12-23 19:14:54

标签: jquery html css

我在使用选框插件时遇到问题,我希望当窗口小于900像素时开始选框,否则该选项将无法运行,但是当我运行窗口调整大小事件时,正在创建选取框时代的潮流,一个在另一个之上, 这是代码:

var resizeTimer;

$(window).on('resize', function(e) {

clearTimeout(resizeTimer);
resizeTimer = setTimeout(function() {
if ($(window).width() < 900) {
        $('.footer').marquee({
            //speed in milliseconds of the marquee
            duration: 10000,
            //gap in pixels between the tickers
            gap: 100,
            //time in milliseconds before the marquee will start animating
            delayBeforeStart: 1000,
            //'left' or 'right'
            direction: 'left',
            //true or false - should the marquee be duplicated to show an effect of continues flow
            duplicated: true
        });

    }
    else {

    }


 }, 500);

});

<div class="footer">
    <div class="pueblatemp">Puebla</div>
    <div class="warlotemp">Warlo</div>
    <div class="difference">Difference</div>
    <div class="time">Time</div>
</div>

1 个答案:

答案 0 :(得分:0)

我会继续打电话

import java.io.*;
import java.util.*;

public class test {
    public static void main (String [] args) throws IOException {
        BufferedReader f = new BufferedReader(new FileReader("test.in.txt"));
        PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("test.out.txt")));
        StringTokenizer st = new StringTokenizer(f.readLine());
        int i1 = Integer.parseInt(st.nextToken());    // first integer
        int i2 = Integer.parseInt(st.nextToken());    // second integer
        out.println(i1+i2); // output rresult
        f.close();
        out.close();     
        // close the output file
      }
}

当您的条件满足时,事件不再受约束。