我有这个WordPress网站。当加载DOM时,我有这个元素。
\[\[https?:\/\/vimeo\.com\/[^\]]*?(\d+)\]\]
我想在加载DOM之前用1,600替换1,300。这可能用PHP吗?
我尝试过.str_replace()方法。
<div class="agents-usp">
<p>Search through more than 1,300 shipments including:</p>
</div>
不确定如何处理此事。
答案 0 :(得分:1)
我通过将它添加到functions.php来解决它:
add_filter('gettext', 'translate_reply');
add_filter('ngettext', 'translate_reply');
function translate_reply($translated) {
$translated = str_ireplace('1,300', '1,600', $translated);
return $translated;
}
适用于WordPress!
答案 1 :(得分:0)
jQuery( document ).ready(function() {
var strNewString = jQuery('.agents-usp').html().replace(/1,300/g,'1,600');
jQuery('.agents-usp').html(strNewString);});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="agents-usp">
<p>Search through more than 1,300 shipments including:</p>
</div>