2
下面的代码中的onclick
未正确触发警报。Onclick警告字符串
这里是我的代码:
function alert_phrase(id){
var value = document.getElementById(id).value;
alert(value);
}
<div id="exp" style="background-color: white;">
<p id="content-exp" style="color: red;">HELLO WORLD!</p>
<input name="phrase" Placheholder="Enter text here" id="phrase" />
<button onclick='alert_phrase(phrase)'>Alert this sentence</button>
</div>
谢谢!它的工作@rfornal – willy
很高兴我可以协助。当我自己想念这些东西时,我发现它很粗糙......比我想要的更频繁。 – rfornal