我编写了以下几行代码,并希望在按下按钮后更改文本,但该按钮不起作用。你能找出问题所在吗?
var omari = "Omari Lamar";
function omari (){
el = document.getElementById('slice');
el.textContent = omari + "Is a computer Programmer!";
}
<html>
<head>
<title></title>
</head>
<body>
<h1>Title Example</h1>
<button onclick="omari();">Click me</button>
<div id="slice">
sample text
</div>
<script src="app.js"></script>
</body>
</html>
最佳答案
将代码更改为:
var omariName ="Omari Lamar";
function omari (){
el = document.getElementById('slice');
el.textContent = omariName + "Is a computer Programmer!";
}
关于javascript - JavaScript辅助代码,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37129829/