【发布时间】:2018-12-04 19:58:10
【问题描述】:
<body>
<form action="http://google.com/search" method="GET">
<label for="keyword">Keyword: </label>
<input type="text" name="q" placeholder="Search Keyword" id="keyword">
<label for="site">Site: </label>
<input type="text" placeholder="Site" id="site">
<input type="submit" value="Google Search" onclick="well();">
</form>
<script >
function well(){
var something = document.getElementById("site").value;
alert(something);
}
</script>
所以我想要的是:
在第一个输入中,您搜索要在 google 上搜索的关键字。
在第二个输入中,您输入要搜索的链接以查看它是否出现在第一页上
-
单击按钮使其搜索并使我的脚本在该页面上运行。
var myList = []; var x = document.querySelectorAll("#rso h3"); for(var i=0; i<x.length; i++){ myList.push(x[i].textContent); } console.log(myList);
上面的代码可以找到h3标签。
但是我怎样才能通过点击按钮来实现呢?
【问题讨论】: