Javascript Basics Tutorial: DOM and HTML
Change html content
innerHTML
Let’s write it below An example, the code is as follows:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div name="test" class="dv" id="dv">php 中文网</div>
<script type="text/javascript">
var div = document.getElementById("dv");
var test = div.innerHTML = "php.cn";
alert(test);
</script>
</body>
</html>As in the above code, first we get the element node through the id, then change the value and assign it to the variable test, and then output
Change html attributes, the code is as follows
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<img src="https://img.php.cn/upload/course/000/000/010/582eab68f0bdb633.jpg" name="image" id="image"
width="50" height="50">
<script type="text/javascript">
//注释这段代码,看一下,是一张图,运行之后,显示的不是原图,是另外一张图
document.getElementById("image").src="https://img.php.cn/upload/course/000/000/010/582eab9aa05cd314.jpg";
</script>
</body>
</html>
new file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<div name="test" class="dv" id="dv">php 中文网</div>
<script type="text/javascript">
var div = document.getElementById("dv");
var test = div.innerHTML = "php.cn";
alert(test);
</script>
</body>
</html>
Preview
Clear
- Course Recommendations
- Courseware download
The courseware is not available for download at the moment. The staff is currently organizing it. Please pay more attention to this course in the future~
Students who have watched this course are also learning
Let's briefly talk about starting a business in PHP
Quick introduction to web front-end development
Large-scale practical Tianlongbabu development of Mini version MVC framework imitating the encyclopedia website of embarrassing things
Getting Started with PHP Practical Development: PHP Quick Creation [Small Business Forum]
Login verification and classic message board
Computer network knowledge collection
Quick Start Node.JS Full Version
The front-end course that understands you best: HTML5/CSS3/ES6/NPM/Vue/...[Original]
Write your own PHP MVC framework (40 chapters in depth/big details/must read for newbies to advance)
















