然后替换嵌套的Elemetn的IMG SRC,而无需ID

发布于 2025-02-07 08:15:25 字数 335 浏览 1 评论 0原文

我有一个HTML结构,我们无法在生成时更改。

我需要寻找一个特定的IMG SRC,我需要原始的SRC作为Val,然后用我们自己的自定义替换SRC。

结构看起来像这样:

<span id="edit5_WMFStream">
   <div>
      <img src="...">
   </div>
</span>

我想寻找以WMFStream结尾的跨度ID,我没有什么可以ID嵌套的DIV,然后是IMG。已经尝试了几件事,但是到目前为止,甚至无法选择DIV,Letalone img然后是SRC。

I have a HTML structure that we cannot change as it is generated.

I need to look for a specific img src, I need the original src as a val, and also then replace the src with our own custom one.

The structure looks like this:

<span id="edit5_WMFStream">
   <div>
      <img src="...">
   </div>
</span>

I want to look for the span id ending with WMFStream, and I have nothing to id the nested div and then img. Have tried several things but so far can't even get to select the div, letalone the img then src.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

绿萝 2025-02-14 08:15:25

也许您可以使用QuerySelector来参考图像

document.querySelector("#edit5_WMFStream img")

maybe you can use querySelector to ref the image

document.querySelector("#edit5_WMFStream img")
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文