开发者

Change Div ID to Validate

开发者 https://www.devze.com 2023-02-19 09:38 出处:网络
I am using a lightweight CMS that has the option to repeat regions. In order for the region to be repeatable, it must have an id. When the region is repeated so is the id. This causes my code to inval

I am using a lightweight CMS that has the option to repeat regions. In order for the region to be repeatable, it must have an id. When the region is repeated so is the id. This causes my code to invalidate.

I was hoping there was a way to change all matching id's (example) to (example-1), (example-2), etc... so that it would validate. I was able to do this through JQuery, but it still did not validate (I am assuming because Javascript i开发者_如何学Gos client side), which is why I though PHP might work.

Thank you for your time, Andre


It won't validate through the W3C validator because it just processes the HTML.

Why don't you change them, and you can't do it manually, use DOMDocument (or equivalent).

  1. Iterate through the elements with id that isn't unique.
  2. Tack on a number.
  3. Save back.
0

精彩评论

暂无评论...
验证码 换一张
取 消