我现在已经建立了一个视频播放器对象,该对象在video
中有一个div
。它还存储info
。我创建了这个对象,然后appendChild
这个对象。那么如何在info
被使用后重新获得appendChild
?
function Video_Player() {
this.box = document.createElement("div");
this.player = document.createElement("video");
this.info = "-----info-----";
this.Build = function() {
this.box.style = "background-color:red; width:200px; height:200px;";
this.player.style = "width:200px; height:150px;";
this.player.controls = true;
this.box.appendChild(this.player);
};
this.getBuild = function() {
return this.box;
};
}
var content = document.getElementById("content");
// Build Object
var player = new Video_Player();
player.Build();
content.appendChild(player.getBuild());
// Print id
console.log("id before appendChild: " + player.info);
// re get the 'object' id
console.log("id after appendChild: " + content.querySelector("div").info);
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<div id="content"></div>
</body>
</html>