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

210
Views
Icons not displaying on first load, but show up on refresh

function mobileView() {
  if ($(window).width() < 767) {
    if ($('#teaser #ai').length) {
      $('#ai').find('.icon-wrp').html(`<div class='icon-wrp'><span aria-hidden='true' role='img' class='custom-icons'>icon2-1</span></div>`);
    }
    if ($('.teaser #as').length) {
      $('#as').find('.icon-wrp').html(`<div class='icon-wrp'><span aria-hidden='true'  role='img' class='custom-icons'>icon2-2</span></div>`);
    }
    // AD product condition check
    if ($('.teaser #ad').length) {
      $('#ad').find('.icon-wrp').html(`<div class='icon-wrp'><span aria-hidden='true'  role='img' class='custom-icons'>icon2-3</span></div>`);
    }
  } else {
    // will trigger for desktop device
    if ($('.teaser #ad').length) {
      $('#ad').find('span').text('icon1-1');
    }
    if ($('.teaser #as').length) {
      $('#as').find('span').text('icon1-2');
    }
    if ($('.teaser #ai').length) {
      $('#ai').find('span').text('icon1-3');
    }
  }
}
$(document).ready(function(){
  mobileView();
 )};
<div class='icon-wrp'>
  <span aria-hidden='true' role='img' class='custom-icons'>icon1-1</span></div>
  <div class='icon-wrp'>
  <span aria-hidden='true' role='img' class='custom-icons'>icon1-2</span></div>
  <div class='icon-wrp'>
  <span aria-hidden='true' role='img' class='custom-icons'>icon1-3</span></div>

For the Desktop view, at the particular position, I've put let's say icon-1 and for the mobile view, there is icon-2. When I move from desktop to mobile view to test from chrome browser, at first icon-1 shows up, and after reloading icon-2 shows up. Also, if I open the URL directly in mobile view only, it's working fine.

I write HTML for the desktop view and the mobile view I used Javascript if the window width <= 767, I changed the logo using the innerHTML.

Expecting - In the mobile view it should be icon-1 and when I change the view to mobile it should change to icon-2 without reloading the page.

about 4 years ago · Juan Pablo Isaza
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!