Attribute selectors, JavaScript and IE8

前端 未结 5 1336
滥情空心
滥情空心 2021-01-18 21:09

I\'m attempting to use attribute selectors and CSS for formatting elements.

The HTML looks like:

User Name
相关标签:
5条回答
  • 2021-01-18 21:34

    You are setting the attribute to JavaScript true and false, not string "true" and "false". This could be interpreted by the browser as 1 and 0 and lead to unwanted results.

    Can you try

    node.setAttribute('highlight', 'true');
    

    ?

    0 讨论(0)
  • 2021-01-18 21:35

    to avoid inevitable cross-browser compatibility issue's with javascript/css I would recommend using jQuery.

    For example, to highlight an element via the jQuery framework this is all that it takes...

    $("div").click(function () {
          $(this).effect("highlight", {}, 3000);
    });
    
    0 讨论(0)
  • 2021-01-18 21:37

    You're using unknown attribute hightlight. It's IE so it supports attributes according to its name (what's seems to be harder than supports every attribute name, but... it's IE).

    Just use class="hightlight" - easier to implement and deal with.

    0 讨论(0)
  • 2021-01-18 21:43

    Make sure you have DOCTYPE defined at the top of the page: Css attribute selector for input type="button" not working on IE7

    0 讨论(0)
  • 2021-01-18 21:53

    Check to make sure you have a DOCTYPE defined at the top of your page: Css attribute selector for input type="button" not working on IE7

    0 讨论(0)
提交回复
热议问题