0

Bear with me, I'm clueless on javascript.

function onTableClick(e) {
    if (e.target.closest('td').innerHTML == "Edit") {
        let myElement = document.querySelector("#JamHeadTable");
        myElement.style.opacity = 1;
        var id = e.target.closest('tr').id.split("_")[1];
        editTableRow(id);
    }
}

I've got this function that has worked fine in Chrome and Edge but I just tried debugging my ASP.Net site in Visual Studio on Internet Explorer 11 and it breaks on the first line:

 if (e.target.closest('td').innerHTML == "Edit")

Is there an equivalent I can use other than e.target.closest('td') to make it IE11 compatible? Baring in mind I also use e.target.closest('tr') a couple of lines down.

jamheadart
  • 5,047
  • 4
  • 32
  • 63
  • [Always look at MDN first](https://developer.mozilla.org/en-US/docs/Web/API/Element/closest) to find polyfills – mplungjan May 05 '20 at 08:35
  • I don't know what a polyfill is – jamheadart May 05 '20 at 08:37
  • Now you know :) You did not need to know the word to look at the function at MDN – mplungjan May 05 '20 at 08:37
  • 1
    It's way's of making old browsers run new JS functions,.. There is also something called trans-piling that add new syntax support, you might need to look into that too if you want to use modern JS features on out-dated browsers. – Keith May 05 '20 at 08:39
  • I copy-pasted the closest polyfiller into my page scripts and it's working as intended so now I get the purpose, but I'll have a google of trans-piling too. – jamheadart May 05 '20 at 08:44

0 Answers0