JavaScript / Object / document.title / 문서의 제목을 가져오거나 변경하는 속성
.title
.title 속성으로 문서의 제목을 가져오거나 변경할 수 있습니다.
문법 1
document.title
문서의 <title> 태그의 내용을 반환합니다.
문법 2
document.title = 'ABC'
문서의 <title> 태그의 내용을 ABC로 바꿉니다.
예제
문서의 제목 JavaScript를 출력하고, 제목을 CODING FACTORY로 바꿉니다.
<!doctype html> <html lang="ko"> <head> <meta charset="utf-8"> <title>JavaScript</title> <style> body { font-family: Consolas, monospace; } </style> </head> <body> <script> document.write ( '<p>' + document.title + '</p>' ); document.title = 'CODING FACTORY'; </script> </body> </html>