var topClick = function() {
child = this.parentNode.parentNode.parentNode.parentNode;
child.parentNode.removeChild(child);
var theFirstChild = document.querySelector(".m-ctt .slt");
data[child.getAttribute("data-id")].rank = 5;
insertBlogs();
};
Run Code Online (Sandbox Code Playgroud)
如您所见,我的代码中有一部分是这样的:
this.parentNode.parentNode.parentNode.parentNode;
Run Code Online (Sandbox Code Playgroud)
有没有其他方法来优化代码(不使用jQuery)?
javascript ×1