0
我想通過在JS中用.TextContent覆蓋HTML來顯示消息嘿朋友。所以,而不是隻是說嘿!我希望它說嘿朋友!如何使用.TextContent顯示文本?
HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>friends</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<!-- This links to the js code specific for this page -->
<script src="multiwrites.js"></script>
<script src="multiwrites2.js"></script>
</head>
<body>
<div id="title">Hey!</div>
</body>
</html>
的Javascript
var message;
message = 'Hey Friends';
var elName = document.getElementById('title');
elName.textContent = message;
什麼問題? –
它的作品只是確保你的'