How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code?

前端 未结 25 3334
谎友^
谎友^ 2020-11-22 06:19

How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code?

I tried this, but

25条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 06:49

    This answer got me 90% of the way there. I found the rest of my answer on the Microsoft site here.

    The code below is what I'm using to target all ie by adding a .ie class to

    Use jQuery (which deprecated .browser in favor of user agents in 1.9+, see http://api.jquery.com/jQuery.browser/) to add an .ie class:

    // ie identifier
    $(document).ready(function () {
      if (navigator.appName == 'Microsoft Internet Explorer') {
        $("html").addClass("ie");
      }
    });
    

提交回复
热议问题