[출처] https://www.w3schools.com/jsref/dom_obj_event.asp
HTML DOM Event Object
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
www.w3schools.com
Description
substr() 메서드는
- 문자열의 일부를 추출합니다.
- 지정된 위치에서 시작하고 지정된 수의 문자를 반환합니다.
- 원래 문자열을 변경하지 않습니다.
- 문자열 끝에서 문자를 추출하려면 음수 시작 위치를 사용하십시오.
See Also:
Related Pages
구문
string.substr(start, length) |
매개변수
Parameter |
Description
|
start
|
필수사항
시작 위치입니다.
첫 번째 문자는 인덱스 0에 있습니다.
start가 길이보다 크면 substr()은 ""를 반환합니다.
start가 음수이면 substr()은 문자열의 끝부터 계산합니다.
|
length
|
선택사항
추출할 문자 수입니다.
생략하면 문자열의 나머지 부분을 추출합니다.
|
Return Value
Type |
Description
|
A string
|
추출된 부분이 포함된 문자열입니다. 길이가 0이거나 음수이면 빈 문자열이 반환됩니다.
|
<p id="demo"></p>
<script>
let text = "Hello world!";
let result = text.substr(0, 5);
document.getElementById("demo").innerHTML = result;
</script>
▶ 실행 값 : Hello
<p id="demo"></p>
<script>
let text = "Hello world!";
let result = text.substr(-6, 6);
document.getElementById("demo").innerHTML = result;
</script>
▶ 실행 값 : world!
[PHP]date()_날짜, 요일, 시간, 달력 관련 함수 (0) | 2023.07.24 |
---|---|
[PHP]substr()_문자열(글자) 자르기 (0) | 2023.07.22 |
[Javascript]HTML DOM Events 목록(자바스크립트 이벤트 목록) (0) | 2023.07.18 |
[CSS]웹페이지 인쇄(출력) 레이아웃(가로세로), 배경인쇄 설정 방법 (0) | 2023.04.25 |
[OS]Windows10, 11 OS에서 네트워크 파일 및 인쇄 공유하기 (0) | 2023.04.07 |
댓글 영역