Search code examples
htmljqueryjquery-selectorsinternet-explorer-11

Custom attribute selector not working in IE11


Does anyone know why the custom attribute selector is not working in IE11 or is there any other alternative to select custom attributes? My code which works on Chrome:

$("[aria-label='" + tempSearchString + "']")
        .parent()
        .css({
          "background-color": "#ae924d",
          "color": "white",
          "cursor": "pointer"
});

I also tried it with a filter but it didn't seem to work in IE:

$("abbr").filter("[aria-label='" + tempSearchString + "']")

Solution

  • The problem was in React library that I was using which created those custom attributes and it put some "invisible" characters at the beginning/end of the custom attribute. When I was comparing strings of tempSearchString and attribute that I was trying to catch they looked the same in writing but Text Compare still found a difference. I decided not to use this library and wrote my own code for that problem.