
before()와 after()의 사용법 ▶ before(): 선택한 요소 바로 앞에 새로운 요소나 콘텐츠를 추가합니다.▶ after( ) : 선택한 요소 바로 뒤에 새로운 요소나 콘텐츠를 추가합니다.before ( ) 예시위 코드를 실행한 결과는 다음과 같습니다.
[추가] 버튼을 클릭하면 마지막 요소 바로 앞에 새로운 요소를 추가합니다.after ( ) 예시위 코드를 실행한 결과는 다음과 같습니다.
[추가] 버튼을 클릭하면 중간요소 바로 뒤에 새로운 요소를 추가합니다.레퍼런스(Reference)Description:Insertcontent, specifiedbytheparameter, beforeeachelementinthesetofmatchedelements.versionadded:1.0.before(content[, content])contentType:htmlStringorElementorTextorArrayorjQueryHTMLstring, DOMelement, textnode, arrayofelementsandes.api.jquery.comDescription:Insert content, specified by the parameter, after each element in the set of matched elements.version added: 1.0.after (content [,content]) content Type: htmlString or Element or Text or Array or jQuery HTML string, DOM element, text node, array of elements and text nodes, or jQuer… api.jquery.com