I have a bunch of <P>
tags in an HTML file that I would like to append a unique value to, for example, my HTML file has the following (i've dumped this HTML file into a PHP variable using file_get_contents
):
<P> ... data ... </P>
<P> ... data ... </P>
<P> ... data ... </P>
<P> ... data ... </P>
<P> ... data ... </P>
I would like to change it so it reads this instead:
<P id='unique1'> ... data ... </P>
<P id='unique2'> ... data ... </P>
<P id='unique3'> ... data ... </P>
<P id='unique4'> ... data ... </P>
<P id='unique5'> ... data ... </P>
Since this is a regular HTML file, there are other tags that may reside in the file as well (such as <HTML>
, <HEAD>
, <STYLE>
, <BODY>
, etc., but I want to append a unique id to ALL <P>
tags
` tags in Javascript, forgoing ids altogether.
– deceze Jan 24 '11 at 09:16