Yobd Digital Yobd Digital - 2 years ago 101
Javascript Question

jQuery functions not working in IE or on mobile devices

Several of my jQuery functions aren't working in IE or on my iOS device. I don't have an Android so I don't know about that.

Function One:

function keepGoing(anchor, id, scrollSpeed = 1000 ) {
$(anchor).click(function() {
$('html, body').animate({
scrollTop: $(id).offset().top
}, scrollSpeed );

Function Two:

function showOnScroll(targetClass,cssAttr,attrValue) {
$(window).scroll(function(event) {

$(targetClass).each(function(i, el) {
var el = $(el);
if (el.visible(true)) {


Answer Source

Problem One: function parameters default set

Function parameter defaults is very new syntax only added in ECMAScript 2015. Use something like this instead:

function(param) {
  if (param === undefined) param = val;
    // ...

Problem Two:

The second problem was IE and the mobile browsers don't like margin:unset; but prefer margin:0;

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download