今天有一段code:
var parents = a.parentNode.parentNode.parentNode.parentNode;
被唸說parentNode太長了...
查了一下pur js有沒有類似jquery的closest,結果是沒有的...還是自刻個func
reference: How to find and access parent nodes via JavaScript
Find the closest ancestor element that has a specific class
沒有留言:
張貼留言