我试图在javascript for循环中访问和显示php数组的元素,每当我尝试注销一个值时,它总是返回空白,我不知道为什么。
for(let i=0;i<"<?php echo sizeof($response['results']); ?>"; i++) {
console.log(i);
let divElement = document.createElement("div");
divElement.className = "col col-6 col-md-4 col-lg-3";
let h4Name=document.createElement('h4');
h4Name.className="name";
h4Name.innerHTML="<?php echo $response['results'][i]['name']?>;"
console.log("<?php echo $response['results'][i]['name']?>");
divElement.appendChild(h4Name);
let h4Address=document.createElement('h4');
h4Address.className="address";
h4Address.innerHTML="<?php echo $response['results'][i]['formatted_address']?>";
divElement.appendChild(h4Address);
document.querySelector(".row").appendChild(divElement);
}
呼啦一阵风
相关分类