嗨,我想在innerHTML中做一個href但是我得到了錯誤或者它正在工作。我想從API中創建一個數據,然後將其複製並放入瀏覽器。當我試圖代碼,將成爲+ item.title而是去,我得到的數據鏈路從我的API在innerHTML中的href
<html>
<head>
<title>JSON/Atom Custom Search API Example</title>
</head>
<body>
<div id="content"></div>
<script>
function hndlr(response) {
for (var i = 0; i < response.items.length; i++) {
var item = response.items[i];
// in production code, item.htmlTitle should have the HTML entities escaped.
document.getElementById("content").innerHTML +="<br>"+ item.title + "<br>" +"<a href='+item.title'>Google</a>" ;
}
}
</script>
<script src="https://www.googleapis.com/customsearch/v1?q=query&cx=004123968310343535430%3Aaxml6iel9yo&key=AIzaSyDxPcphnrcN9_dfkRkFTbwkv44m1-HI1Hg&callback=hndlr">
</script>
</body>
</html>
!好抓住+1 :) –