<!DOCTYPE html>
<html>
<body>

<h3>演示如何访问Search字段</h3>

<input type="search" id="mySearch" placeholder="搜索..">

<p>点击按钮来获得 search 字段的占位符文本。</p>

<button onclick="myFunction()">试一下</button>

<p id="demo1"></p>
<p id="demo2"></p>

<script>
function myFunction() {
    var x = document.getElementById("mySearch").placeholder;
    document.getElementById("demo1").innerHTML = x;
    var y = document.getElementById("mySearch").value;
    document.getElementById("demo2").innerHTML = y;
}
</script>

</body>
</html>