Skip to content

Instantly share code, notes, and snippets.

@AndersDJohnson
Last active June 5, 2019 13:36
Show Gist options
  • Select an option

  • Save AndersDJohnson/7c8db19d944b758b1c73 to your computer and use it in GitHub Desktop.

Select an option

Save AndersDJohnson/7c8db19d944b758b1c73 to your computer and use it in GitHub Desktop.
jQuery IE8 HTML parse bug

Apparently in IE8 only, there are bugs with the jQuery HTML parser.

var $el = $('<span class="sub-features">');
// $el[0] == undefined

Only this works:

$('<span class="sub-features"></span>');
// $el[0] == {...}

or this (without attributes in the tag):

$('<span>').addClass('sub-features');
// $el[0] == {...}

Apparently this only affect inline elements - <b ...>, etc. Block-level elements such as <div ...> seem fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment