gpt4 book ai didi

javascript - 如何从弹出窗口检索图像 src 属性到父页面

转载 作者:行者123 更新时间:2023-12-02 18:47:37 25 4
gpt4 key购买 nike

我从弹出窗口中调用 js 函数,如下所示:

<img onclick=parent.updateFunction('"+ item.id +"','"+ item.image +"','"+ item.label +"'); src=/mypath/ />

这就是我尝试在父页面中显示 src 属性的方式:

  function updateFunction(id, image, label) {

alert($(this).attr('src'));

结果暂时未定义...

最佳答案

您需要将 this.src 传递给该函数。请参阅fiddle

<img src="http://jsfiddle.net/img/logo.png" onclick ="update(this.src)" />

//script
update = function(src){
alert(src);
}

关于javascript - 如何从弹出窗口检索图像 src 属性到父页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16193908/

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