gpt4 book ai didi

php - 在 jQuery 中更改一堆 img 标签的属性是否比 PHP 更容易?

转载 作者:行者123 更新时间:2023-12-01 06:40:10 26 4
gpt4 key购买 nike

我正在考虑用 PHP 编写一些代码来更改图像的所有 id 以匹配其 alt。在 jQuery 中这会更容易实现吗?

我需要做的是走这条线

img alt="拼图"src="images/cole.jpg"alt="这就是我"style="display:none;"/>

并做到

img id="拼图"alt="拼图"src="images/cole.jpg"alt="这就是我"style="display:none;"/>

最佳答案

尽可能转移到服务器。另外,如果用户打开了 javascript 拦截器怎么办?

但我不得不问你为什么要这样做?

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").

但是 alt 标签可能有空格,这意味着您可以设置一个可能无效的 id!

编辑

现在您已经编辑了答案:第一个 img 标签是无效的 html,你不能有 2 个 alt 标签,jQuery 将无法处理它。

关于php - 在 jQuery 中更改一堆 img 标签的属性是否比 PHP 更容易?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5650954/

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