codestates / codestates/Lollin-server

[error handling] jquery find 함수

Open
#24 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
0
Forks
0
PR merge metrics
No merged PRs in 30d

Description

**어떤 에러인가요?**
* jquery의 find 함수를 사용하면 자식노드 뿐만 아니라 기준 노드 아래 모든 노드를 탐색하는 문제가 있었다.

**에러 핸들링 방법**
* 기준 노드의 자식 노드의 갯수를 센다.
* find 함수의 매개변수 selector 에 eq(child index) 조건을 걸어 더이상 밑으로 내려가지 않도록 하였다.
```let contentNum = explain.nextAll('.attribute-change').length;
let contents = [];
for (let j = 0; j < contentNum; j++) {
let str = arr[i]
.find(`.attribute-change:eq(${j})`)
.text()
.replace(/[\r\n\t]/g, '');
contents.push(str);
}```

**에러 핸들링을 위해 참고한 레퍼런스 링크**
[`링크`](https://androman.tistory.com/39)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.