使用jQuery的
attr()
使用回调函数来追加值。
例如
const suffix = "/Demo_App";
// all elements with `src` attribute
$("[src]").attr("src", (_, src) => src + suffix)
// all elements with `href` attribute
$("[href]").attr("href", (_, href) => href + suffix)
一如既往
you might not need jQuery
const suffix = "/Demo_App";
document.querySelectorAll("[src]").forEach(elt => {
elt.src += suffix
})
document.querySelectorAll("[href]").forEach(elt => {
elt.href += suffix
})