如何在 PHP 中使用 getElementById
我正在尝试选择具有特定 ID 的动态生成页面 (drupal6) 的所有图像,以便我可以应用一个类。
我已经阅读了 php.net 上的 getElementById 和 setIdAttribute 文档,但这些文档对我来说没有多大意义,并且我尝试声明 ID 然后调用它的尝试不起作用。我也浏览了这里的各种类似的帖子,但效果并没有更好。
我实际上只是在寻找一个基本示例,说明如何一起使用这两个函数来获取特定 ID 的图像。
编辑 - 很抱歉我含糊其辞 - 我不能使用 Jquery/javascript (这是我的第一选择)。根据我正在做的事情,我不能冒 FOUC 的风险。 jquery/javascript 将是我唯一的选择吗? - 如果可能的话我更喜欢 PHP
谢谢 斯蒂芬妮
I'm trying to select all of the images of a dynamically produced page (drupal6) that have a specific ID, so I can apply a class.
I've read the docs on php.net for getElementById and setIdAttribute but the docs don't make much sense to me, and my attempts at declaring the ID then calling it don't work. I've also looked through the various similar posts here and have not fared better.
I'm really just looking for a base example of how I'm supposed to use these two functions together to get images of a specific ID.
EDIT -
I'm sorry I was vague - I can't use Jquery/javascript (it was my first choice). based on what I'm doing I can't risk a FOUC. is jquery/javascript going to be my only choice? - I would prefer PHP if possible
Thanks
Stephanie
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里有一些快速而肮脏的代码作为起点:
Here you are some quick and dirty code to take as starting point:
为此,您应该使用 javaScript。 使用 jQuery 非常简单,您可以使用:
如果您想捕获特定图像,
You should use javaScript for that. Using jQuery is pretty straightfoward
if you want to catch a specific image, you can use: