我想替换某个<div>
中的属性值。我希望它更改为CMS提供的值。该变量有多个<div>
。
示例:
<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>
我希望将代码rel =“fancy”替换为rel = id-number(由CMS提供)。所以代码必须是这样的:
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.
这必须是结果:
<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>
这个数字每次都是唯一的,以确保图像保留在自己的fancybox中并由CMS提供。我可以操作一个模板以确保插入数字,但不能放在“花式”所在的位置......