search

Home  >  Q&A  >  body text

javascript - Now the page will only be triggered once when it is opened. How can it be triggered multiple times?

if(document.getElementById('heldnav').offsetTop < (188+$('#img_img').height())){
    alert(1)
  $("#heldnav").addClass("normal_0");
}
扔个三星炸死你扔个三星炸死你2834 days ago813

reply all(6)I'll reply

  • 我想大声告诉你

    我想大声告诉你2017-06-15 09:25:43

    Are you listening to some floating nav? You should first determine in what state you want to trigger this listener, such as a change in browser window size or something else, and then write your code in the corresponding event, such as resize, etc.

    reply
    0
  • 滿天的星座

    滿天的星座2017-06-15 09:25:43

    You should monitor scrolling, bind the scroll event to the element you want to monitor, and check the changes in real time

    reply
    0
  • 怪我咯

    怪我咯2017-06-15 09:25:43

    Add to the corresponding event to monitor

    reply
    0
  • 淡淡烟草味

    淡淡烟草味2017-06-15 09:25:43

    You need to add the corresponding scroll listening event to the floating object, and then do the judgment and processing in the method

    reply
    0
  • ringa_lee

    ringa_lee2017-06-15 09:25:43

    Either add timer setInterval/setTimeout or add event function to achieve real-time monitoring

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-06-15 09:25:43

    Either a timer or add an event listener. It depends on your needs. In short, it's impossible to just write a method and let it execute multiple times by itself, right?

    reply
    0
  • Cancelreply