javascript - Change all text on page with innerHTML -
i want change text on page, got value "yes".how can change "yes"-value on page?
i want if value of text = "yes", must replaced <span class='ic ic-normal ic-icon-yes'></span>
this current code:
<?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 $_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'] $_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;?>
text inside td-class loaded dynamically. elements not have unique id.
how can achieve this?
if correct understand problem, want change elements containing text equal "yes" pattern. try script achieve that:
$('*').filter(function() { return $(this).text()=='yes' }).each(function() { this.textcontent = "<span class='ic ic-normal ic-icon-yes'></span>" });
or in pure javascript:
var allelements = document.body.getelementsbytagname("*"); for(var = 0; < allelements.length; i++) { var text = allelements[i].innerhtml; if (text == 'yes') { allelements[i].innerhtml = "<span class='ic ic-normal ic-icon-yes'></span>"; } }
Comments
Post a Comment