jQuery wrapInner() 메서드
예시
각 <p> 요소의 콘텐츠 주위에 <b> 요소를 래핑합니다.
$("button").click(function(){
$("p").wrapInner("<b></b>");
});
정의 및 사용
wrapInner() 메서드는 선택한 각 요소의 콘텐츠(innerHTML) 주위에 지정된 HTML 요소를 래핑합니다.
통사론
$(selector).wrapInner(wrappingElement,function(index))
Parameter | Description |
---|---|
wrappingElement | Required. Specifies what HTML element(s) to wrap around the content of each selected element Possible values:
|
function(index) | Optional. Specifies a function that returns the wrapping element
|
직접 해보십시오 - 예
document.createElement()를 사용하여 요소를 만들고 선택한 각 요소의 내용을 감싸는 방법.
를 사용하여 내용 줄 바꿈 함수를 사용하여 선택한 각 요소의 내용을 줄 바꿈할 항목을 지정합니다.