Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
Change 'resize' to 'onload' JS

Currently, this script only works when I adjust the window - I'd like it to work on load but do not know-how. I think this is simple but I can't figure it out.

      $(window).on('resize', function() {
if($(window).height() > 300) {
    $('.card').addClass('hover');
    $('.card').removeClass('no');
}else{
    $('.card').addClass('no');
    $('.card').removeClass('hover');
}

})

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Just create a function and execute it onload and as a event listener of the onresize

function resizeHandler() {
  if ($(window).height() > 300) {
    $('.card').addClass('hover');
    $('.card').removeClass('no');
  } else {
    $('.card').addClass('no');
    $('.card').removeClass('hover');
  }
}

$(window).on('resize', resizeHandler);
$(document).ready(resizeHandler);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!