下面onclick
的代码中没有正确触发警报.
这是我的代码:
function alert_phrase(id){
var value = document.getElementById(id).value;
alert(value);
}
Run Code Online (Sandbox Code Playgroud)
<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>
Run Code Online (Sandbox Code Playgroud)
javascript ×1