https://stackoverflow.com/questions/59455136/how-to-support-closest-in-ie11
https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#polyfill
https://segmentfault.com/q/1010000006796739
Polyfill的用法:直接将代码,放到js中就行了,例如:
<script type="text/javascript">
//删除当前记录
$(".option-tipBox .text:first-child").click(function () {
//这里用到了查找父元素的方法
var optionBox = $(this)[0].closest('.option-box');
optionBox.parentNode.removeChild(optionBox);
});
//解决ie不支持closest方法(用于查找父元素)
if (!Element.prototype.matches) {
Element.prototype.matches =
Element.prototype.msMatchesSelector ||
Element.prototype.webkitMatchesSelector;
}
if (!Element.prototype.closest) {
Element.prototype.closest = function(s) {
var el = this;
do {
if (Element.prototype.matches.call(el, s)) return el;
el = el.parentElement || el.parentNode;
} while (el !== null && el.nodeType === 1);
return null;
};
}
</script>