jQuery prepend() 메서드
예시
모든 <p> 요소의 시작 부분에 내용 삽입:
$("button").click(function(){
$("p").prepend("<b>Prepended text</b>");
});
정의 및 사용
prepend() 메서드는 선택한 요소의 시작 부분에 지정된 내용을 삽입합니다.
팁: 선택한 요소의 끝에 내용을 삽입하려면 append() 메서드를 사용합니다.
통사론
$(selector).prepend(content,function(index,html))
Parameter | Description |
---|---|
content | Required. Specifies the content to insert (can contain HTML tags)
Possible values:
|
function(index,html) | Optional. Specifies a function that returns the content to insert
|
직접 해보십시오 - 예
prepend() 메서드로 콘텐츠를 삽입합니다.
을 사용하여 선택한 요소의 시작 부분에 내용을 삽입합니다.