gpt4 book ai didi

javascript - Fancybox问题,需要帮助

转载 作者:行者123 更新时间:2023-11-28 10:55:07 24 4
gpt4 key购买 nike

我用从数据库获取的图像制作了一个画廊,并使用Fancybox来显示它。我有一些相同的文章,只是颜色不同,我只显示一个和下面的颜色框来更改颜色。

The problem is that when I click on the button to change the color, picture changes, Fancybox on click displays first picture, not the Current one

部分代码:

JS:

function changeImage(element,id){
var img=document.getElementById(id).src=element;
return false;
}

PHP:

while($row = mysql_fetch_array($sql)){

$prikaz =$row['prikaz'];
$id = $row['id'];
$ime = $row['ime'];
$thumb = $row['thumbs'];
$boja = $row['boja_id'];
$slicka = $row['slika'];
$spec = $row['tekst'];

if ($prikaz == 1){

echo "<table style ='display: inline' align='center'>";
echo "<tr>";
echo "<td><a class='fancybox-effects-a' href='$slicka' ><img id='$id' src='$thumb' alt='' /></a></td>";
echo "</tr>";
echo "<tr><td>";
echo "Boja: ";
$bsql = mysql_query ("SELECT muski.tekst, muski.id,muski.thumbs,boja.bslika FROM boja INNER JOIN muski ON muski.boja_id = boja.id WHERE muski.ime = '$ime' " );

while($res = mysql_fetch_array($bsql)){

$slicica = $res['thumbs'];
$muid = $res['id'];
$kockica = $res['bslika'];
echo "<button id = 'boja' onclick =changeImage('$slicica','$id')><img src= $kockica ></button>";

}

echo "</br>";
echo nl2br($spec);

}

echo "</td>";
echo "</tr>";
echo "</table>";

最佳答案

我找到了解决方案....我修改了js脚本来更改img的父href...它有效...

function changeImage(element,id,staza) {
var img = document.getElementById(id);
img.src= element;
img.parentNode.href=staza;
return false;
}

关于javascript - Fancybox问题,需要帮助,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24881169/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com