1
我有从数据库循环“自动创建”的链接,当我点击一个链接时,它应该显示一个iframe,它只适用于第一个链接。而且不与他人合作...iFrame按钮点击
首先它打印数据的代码
while($row = mysqli_fetch_assoc($wr))
{
printf(nl2br("<a class='questions' id='oldQ'><b>%s</b></a>\n\n"), $row['question'], $row['question']);
}
然后创建
document.getElementById('oldQ').onclick = function() {
var iframe = document.createElement('iframe');
iframe.src = "qa.php";
iframe.class = "iframe";
document.body.appendChild(iframe);
};
我已经删除了“oldQ”和使用' document.getElementsByClassName' with'questions',但现在根本不起作用 – Nezoo
编辑答案 - 因为我们现在查询多个元素,所以我们需要一个for循环。 –
令人惊叹,谢谢 – Nezoo