I need to update a specific attribute's value within certain <div>
elements. This new value will come from our CMS and needs to be applied to multiple instances of the same attribute.
For example:
<div id="1395308878">
<div class="slides_container">
<div><a rel="fancy" href="01.jpg"><img border="0" src="01a.jpg"></a><div>
<div><a rel="fancy" href="02.jpg"><img border="0" src="02a.jpg"></a><div>
<div><a rel="fancy" href="03.jpg"><img border="0" src="03a.jpg"></a><div>
</div>
</div>
<div id="9995308878">
<div class="slides_container">
<div><a rel="fancy" href="04.jpg"><img border="0" src="04a.jpg"></a><div>
<div><a rel="fancy" href="05.jpg"><img border="0" src="05a.jpg"></a><div>
<div><a rel="fancy" href="06.jpg"><img border="0" src="06a.jpg"></a><div>
</div>
</div>
The goal is to replace the rel="fancy"
attribute with rel="id-number"
, where the number is generated by the CMS. The process should look like this:
in the DIV with id="a number" <-- generated by CMS
find the VAR fancy and replace it with the same number <-- that is generated by a CMS.
The desired outcome should be as follows:
<div id="1395308878">
<div class="slides_container">
<div><a rel="1395308878" href="01.jpg"><img border="0" src="01a.jpg"></a><div>
<div><a rel="1395308878" href="02.jpg"><img border="0" src="02a.jpg"></a><div>
<div><a rel="1395308878" href="03.jpg"><img border="0" src="03a.jpg"></a><div>
</div>
</div>
<div id="9995308878">
<div class="slides_container">
<div><a rel="9995308878" href="04.jpg"><img border="0" src="04a.jpg"></a><div>
<div><a rel="9995308878" href="05.jpg"><img border="0" src="05a.jpg"></a><div>
<div><a rel="9995308878" href="06.jpg"><img border="0" src="06a.jpg"></a><div>
</div>
</div>
Each number is unique to ensure images are displayed correctly in their respective fancyboxes, and the numbers themselves are provided by the CMS. While I have the ability to modify a template to insert these numbers, they cannot be directly placed where "fancy" is located...