iOS8 Safari after a pushState the :nth-child() selectors not works

Indeed nth-child doesn’t work on IOS8.

Switching for nth-of-type did the trick for me.

It’s well supported https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-of-type

That said if you want to take no chance, you can detect IOS 8 as follow.

function isIOS8() {
  if ("600.1.4" == $.browser.version || ~navigator.userAgent.indexOf('OS 8_') ){
    return true;
  }
  return false;
}

var i=0,
    $el = $('ul.poll');

if( isIOS8() ){
    $el.find(' li:nth-of-type(' + (i + 1) + ')').text('my first Child');
}else{
    $el.find('.choice:nth-child(' + (i + 1) + ')').text('my first Child');
}

Leave a Comment