gpt4 book ai didi

javascript - 第二次单击时不是 jquery 中的函数错误

转载 作者:行者123 更新时间:2023-11-28 12:35:54 24 4
gpt4 key购买 nike

我在 wordpress 插件中遇到问题。我已经制作了位于该位置的图像区域图。

http://singhalcompetitionclasses.com/newspaper/

在此我创建了两个区域 map 。

当我第一次点击任何区域 map 时,它会显示弹出窗口

但是当我再次点击任何区域 map 时,它会在控制台中出现错误

hello 不是函数

我使用的代码如下:

<script>
function hello(id){
var path = "<?php echo $path; ?>";
alert(id);
var path = path+id+'/'+id+'.jpg';
image = "<img src='"+path+"' id='hello'>";
//alert(image);
jQuery("#hidden").html(image);
var newwindow = window.open(jQuery(this).prop('href'), '', 'height=800,width=800');
// if (window.focus) {
newwindow.focus();
newwindow.document.write( jQuery("#hidden").html() );
//}
return false;
}
</script>

<div style="width: 900px; overflow: scroll; float: left;">
<img src="<?php echo $img_src;?>" id="photo" style="width: 850px;" usemap="#planetmap" />
</div>
<map name="planetmap">
<?php
$sql = mysql_query("select * from epaper");
while($row = mysql_fetch_array($sql)){
$xx = $row['file_id'];
echo '<area shape="rect" style="cursor:pointer;" coords="'.$row['x1'].','.$row['y1'].','.$row['x2'].','.$row['y2'].'" target="_blank" onclick="return hello('.$xx.');" alt="Sun" onmouseover="borderit(this,"black")" onmouseout="borderit(this,"white")">';
}
?>
<div id="hidden" style="display:none;">

</div>
</map>

请大家帮我解决这个问题

最佳答案

您的函数名称用作其中的 html 元素的 ID。它会混淆浏览器。

更改此行的 id:

image = "<img src='"+path+"' id='hello'>";

到(示例):

image = "<img src='"+path+"' id='other_id'>";

关于javascript - 第二次单击时不是 jquery 中的函数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27652657/

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