English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JS 함수를 사용하여 html 요소 내용을 수정하고, 속성 내용을 수정하는 방법

요소 내용 수정:

<body>
	<p id="pid">Hello</p>
	<button onclick="demo()">버튼</button>
	<script>
		function demo(){
			var nv = document.getElementById("pid");
			nv.innerHTML="World";
		}
	</script>
</body>

요소 태그 속성 수정:

<body>
	<a href="http://www.baidu.com/" id="aid" >허허</a>
	<button onclick="demo()">버튼</button>
	<script>
		function demo(){
			document.getElementById("aid").href="http://www.jikexueyuan.com";
		}
	</script>
</body>

이제 저는 여러분께 제공한 JS 함수를 통해 HTML 요소 내용을 수정하고 속성 내용을 수정하는 모든 내용을 정리했습니다. 강의에 많은 지지와 격려 부탁드립니다.

추천 합니다