▶ Javascript는 HTML 페이지를 보다 동적이고 대화식으로 만든다.
실습 : https://www.w3schools.com/html/tryit.asp?filename=tryhtml_scripts_intro
■ HTML <script> 태그
▶ HTML <script> 태그는 클라이언트 측의 스크립트를 정의하는데 사용된다.
▶ <script> 요소는 스크립트 문구를 포함하거나 "src" 속성을 통해 외부 스크립트 파일을 가리킨다.
▶ Javascript의 일반적인 용도는 이미지 조작, 양식 유효성 및 내용의 동적 변경이다.
▶ HTML 요소를 선택하기 위해 자바스크립트에서는 주로 "document.getElementById()" 메소드를 사용한다.
<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>
실습 : https://www.w3schools.com/html/tryit.asp?filename=tryhtml_script
■ Javascript 맛보기
▶ 문구 바꿔보기
document.getElementById("demo").innerHTML = "Hello JavaScript!";
실습 : https://www.w3schools.com/html/tryit.asp?filename=tryhtml_script_html
document.getElementById("demo").style.fontSize = "25px";
document.getElementById("demo").style.color = "red";
document.getElementById("demo").style.backgroundColor = "yellow";
실습 : https://www.w3schools.com/html/tryit.asp?filename=tryhtml_script_styles
document.getElementById("image").src = "picture.gif";
실습 : https://www.w3schools.com/html/tryit.asp?filename=tryhtml_script_attribute
■ HTML <noscript> 태그
▶ HTML <noscript> 태그는 브라우저에서 스크립트를 비활성화했거나 스크립트를 지원하지 않는 브라우저를 사용하는 사용자게 표시할 대체 콘텐츠를 정의한다.
<script>
document.getElementById("demo").innerHTML = "Hello JavaScript!";
</script>
<noscript>Sorry, your browser does not support JavaScript!</noscript>
실습 : https://www.w3schools.com/html/tryit.asp?filename=tryhtml_noscript
출처 : https://www.w3schools.com/html/html_scripts.asp
HTML JavaScript
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
'HTML' 카테고리의 다른 글
HTML / (39) head 요소 (0) | 2023.02.24 |
---|---|
HTML / (38) 파일 경로 (0) | 2023.02.24 |
HTML / (36) iframes (0) | 2023.02.24 |
HTML / (35) id 속성 (0) | 2023.02.24 |
HTML / (34) Class 속성 (0) | 2023.02.22 |