IE8 not refreshing class after attribute value change

后端 未结 2 1520
北荒
北荒 2021-01-05 18:39

Context: I have an HTML page which makes use of HTML5 data- attributes. Some of my CSS styles use attribute selectors to style elements based on the value o

2条回答
  •  迷失自我
    2021-01-05 19:29

    don't use onclick if you have the possibilites of jQuery write it like this

    jQuery('input[type="button"]').click(function() {
      jQuery('div').toggleClass("Test");
    });
    
    jQuery('div').click(function() {
      jQuery('div').attr("data-foo", "baz");
    });
    

    in IE you always must check the javascript-error-console.

    DEMO

提交回复
热议问题