【发布时间】:2015-07-27 09:37:06
【问题描述】:
我想更改页面上的所有文本,其值为“是”。如何更改页面上的所有“是”值?
我只希望如果文本的值 =“是”,则必须将其替换为 <span class='ic ic-normal ic-icon-yes'></span>
这是我当前的代码:
<?php
$_helper = $this->helper('catalog/output');
$_product = $this->getProduct()
?>
<?php if($_additionalgroup = $this->getAdditionalData()): ?>
<section id="additional">
<div class="box-collateral box-additional">
<h2><?php echo $this->__('Additional Information') ?></h2>
<?php $i=0; foreach ($_additionalgroup as $_additional): $i++; ?>
<h3><?php echo $this->__( $_additional['title'] )?></h3>
<table class="data-table" id="product-attribute-specs-table-<?php echo $i?>">
<col width="25%" />
<col />
<tbody>
<?php foreach ($_additional['items'] as $_data): ?>
<?php $_attribute = $_product->getResource()->getAttribute($_data['code']);
if (!is_null($_product->getData($_attribute->getAttributeCode())) && ((string)$_attribute->getFrontend()->getValue($_product) != '')) { ?>
<tr>
<th class="label"><?php echo $this->htmlEscape($this->__($_data['label'])) ?></th>
<td class="data"><?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?></td>
</tr>
<?php } ?>
<?php endforeach; ?>
</tbody>
</table>
<script type="text/javascript">decorateTable('product-attribute-specs-table-<?php echo $i?>')</script>
<?php endforeach; ?>
</div>
</section>
<?php endif;?>
td-class 中的文本是动态加载的。 元素没有任何唯一 ID。
我怎样才能做到这一点?
【问题讨论】:
-
您是否有多个具有相同 id 的元素?
-
@KAG 元素不再有任何 ID,因为它是动态加载的,不可能有唯一 ID
-
你的 DOM 中是否有一个 id="Yes" 的元素?您的代码会查找以这种方式设置样式的元素并替换其中的文本。
-
@LelioFaieta 抱歉,这不正确。我为此更改了我的问题,因为我没有任何唯一 ID
标签: javascript php html innerhtml php-5.5