小编wil*_*lly的帖子

Onclick提醒一个字符串

下面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

2
推荐指数
1
解决办法
345
查看次数

标签 统计

javascript ×1