当按钮被点击时,我需要用DR Smith替换范围标签中的名称。我应该使用带有两个参数的替换(标记,值)函数来完成它。我该怎么做,请帮忙。我写了一段代码,但它不会工作。替换javascript中的文本
<html>
<head>
<script src="q1.js" type="text/javascript"> </script>
</head>
<body>
Dear <span id="salutation">Name</span>;
<p>
It has come to our attention that your invoice
</p>
<button onclick="format()">Format</button>
</body>
</html>
js代码
function format(){
var x = document.getElementsById('salutation')
x.innerhtml = "Dr Smith";
}
'getElementsById' - >'getElementById','innerhtml' - >'innerHTML','格式()' - >'替换( )'(尽管你还没有使用参数) –
'format()'函数在哪里 – Ramanlfc
我改变了它,但它仍然不会工作 – NewProgrammer7