Processing
 

IE8 , jquery addclass not working, neither javascript classname

05/09/2016 14:20#1

Joined at: 4 months ago

Post: 1

Thank: 0

Thanked: 0

I'm trying to add a class to a li in jquery (or javascript). It works fine in FF and Google, but IE8 doesn't seem to recognize the code, because there's no class added.

I'm using jquery 1.9.1, you can see example here:

The thing is I'm using http://mediaelementjs.com/ to add audio (various songs) that on click is reproduced, each of these songs are wrapped in a li in javascript. That's why I need to add each li a class to assign a background-image to each song.

I tried the following, neither works:

/// first code ///    $(document).ready(function() {      $(".mejs li").each(function(i) {          $(this).addClass("at_" + (i+1));      });  });    /// second code ///    $(document).ready(function(){    var i = 1;    $(".mejs li").each( function() {        $(this).attr("class", "at_"+i);        i++;    });  });    /// third code ///    var elements = document.getElementsByTagName("li");  var nameClass = '';  for (i = 0; i < elements.length; i++) {      nameClass =  elements[i].className+" at_"+i;       elements[i].className = nameClass;  }

Similar articles

IE9 dosen't support my Button Tag

4 months ago - Reply: 0 - Views: 14

SSRS 2016 Web protal in IE8

4 months ago - Reply: 0 - Views: 13

how to handle @keyframes not supported by ie9?

4 months ago - Reply: 0 - Views: 5

Detect Windows XP in Firefox with JS

4 months ago - Reply: 1 - Views: 47

IE8 Not showing divs with floats

4 months ago - Reply: 2 - Views: 130

Including ECMA 5 script in IE8

5 months ago - Reply: 1 - Views: 98

XDomainRequest does not work in ie8 & ie9

5 months ago - Reply: 0 - Views: 10

How to minify angular.js?

5 months ago - Reply: 1 - Views: 30

VBA and IE8 - scrape text buried in table

5 months ago - Reply: 1 - Views: 37

Detect http satus IE10

5 months ago - Reply: 0 - Views: 6

how to compress angular.js?

5 months ago - Reply: 0 - Views: 3

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re