모든 사전
jQuery 관련 사전
jquery prepend() 메서드
중국어 번역
최근 업데이트: 2018-05-11 14:48:35
prepend
English [pri:'pend] US [pri:'pend]
vt. 미리 고려하고, 미리 계획하고, premeditate
jquery prepend() 메서드 통사론
기능: prepend() 메서드는 선택한 요소의 시작 부분(아직 내부)에 지정된 내용을 삽입합니다. prepend() 및 prependTo() 메서드는 동일한 효과를 갖습니다. 차이점은 구문에 있습니다. 내용과 선택기의 위치와 prependTo() 함수를 사용하여 내용을 삽입할 수 없다는 사실입니다.
구문: $(selector).prepend(content)
매개변수:
| Parameters | Description |
| content | 필수입니다. 삽입할 콘텐츠를 지정합니다(HTML 태그 포함 가능). |
함수를 사용하여 콘텐츠 추가: 함수를 사용하여 선택한 요소의 시작 부분에 지정된 콘텐츠를 삽입합니다.
구문: $(selector).prepend(function(index,html))
매개변수:
| 매개변수 | Description |
| function(index,html) | 필수입니다. 삽입할 내용을 반환하는 함수를 지정합니다. |
| index | 선택사항. 선택기의 인덱스 위치를 승인합니다. |
| html | 선택사항. 선택기의 현재 HTML을 허용합니다. |
jquery prepend() 메서드 예
<html>
<head>
<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("button").click(function(){
$("p").prepend("<b>Hello world!</b> ");
});
});
</script>
</head>
<body>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
<button>在每个 p 元素的开头插入内容</button>
</body>
</html>온라인 인스턴스를 보려면 "인스턴스 실행" 버튼을 클릭하세요




