我想使用Javascript从样式标记中删除一些规则。 例如:
<style>
@font-face { font-family:"Arial";src:url("#FontID1") format(svg)}
@font-face { font-family:"Nyala";src:url("#FontID0") format(svg)}
.fil2 {fill:#05BAE4}
.fil3 {fill:#373435}
.fil1 {fill:#05BAE4;fill-rule:nonzero}
.fil0 {fill:#11D6CC;fill-rule:nonzero}
.fnt1 {font-weight:normal;font-size:189.311;font-family:'Arial'}
.fnt0 {font-weight:normal;font-size:615.094;font-family:'Nyala'}
</style>
我想删除@ font-face规则并将其替换为其他内容。 谁能告诉我它是如何完成的?
答案 0 :(得分:0)
我尝试添加这个:
<script type="text/plain" id="allFonts">
<style type="text/css">
@font-face {
font-family: MuseoSlab;
src: url('/fonts/Museo_Slab.otf');
}
@font-face {
font-family: MuseoSans;
src: url('/fonts/MuseoSans.otf');
}
@font-face {
font-family: Neuton;
src: url('/fonts/Neuton.otf');
}
@font-face {
font-family: Stag-Medium;
src: url('/fonts/STAG-MEDIUM_0.otf');
}
@font-face {
font-family: STAGSANS;
src: url('/fonts/STAGSANS-MEDIUM_0.otf');
}
@font-face {
font-family: Zapf;
src: url('/fonts/Zapf.otf');
}
@font-face {
font-family: GLSNECB;
src: url('/fonts/GLSNECB.otf');
}
@font-face {
font-family: HELVETIA;
src: url('/fonts/HELVETIA.otf');
}
@font-face {
font-family: "CG Omega";
src: url('/fonts/STAG-MEDIUM_0.otf');
}
@font-face {
font-family: "Eurostile LT Bold";
src: url('/fonts/STAGSANS-MEDIUM_0.otf');
}
</style>
</script>
并在剧本中:
$("style").after($("#allFonts").text());
它正在运作..