【发布时间】:2019-10-29 12:26:28
【问题描述】:
我正在尝试做一个动态内容放大弹出窗口。
这是我当前的代码。
if ($queryResult > 0) {
while ($row = mysqli_fetch_assoc($result)) {
echo "<div class='hvrbox'>
<img src='image/".$row['mImage']."' alt='' class='hvrbox-layer_bottom' />
<div class='hvrbox-layer_top'>
<a href='#posterVid1' class='posterbtn1' id='posterLink1'>Play Trailer</a>
<div id='posterVid1' class='mfp-hide' style='max-width: 75%; margin: 0 auto;'>
<iframe width='853' height='480' src='".$row['mLink']."' frameborder='0' allow='accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture' allowfullscreen></iframe>
</div>
<a class='posterbtn2' href='movie-detail.php?name=".$row['mName']."'>Movie Details</a>
<div class='hvrbox-text'>Me Before You</div>
</div>
</div>";
}
}
这是javascript
$('#posterLink1, #posterLink2, #posterLink3')
.magnificPopup({
type:'inline',
midClick: true // Allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source in href.
})
由于我使用的宏伟弹出窗口仅打开基于id 标记和 JavaScript 中给出的id 的内容,如果我有不同的内容,id 仍然保持不变并且只有按钮一遍又一遍地打开相同的内容,因为id 是相同的。因为我获取的内容来自数据库,所以我不能一遍又一遍地复制代码,只能像在静态页面中那样更改 id。
我做错了什么?
【问题讨论】:
标签: javascript php html magnific-popup