imgタグのsrcの一部をreplaceする
<img src="{$root}img/xxx.jpg">
を
$(function () {
$("img").each(function() {
var replace = null;
var replace = $(this).attr('src').replace(/\{\$root\}/g,'../');
$(this).attr('src',replace);
});
});
すると
<img src="../img/xxx.jpg">
となる。
aタグのhrefなどにも応用できる。
