嗨,您能告诉我如何更改 div 的字体系列。实际上,我有一个选项可以在我的应用程序中更改字体系列。更改字体系列后,它应该反映在所有应用程序中。但对一个 div 更重要(呈现不同的页面)有一些 ID 和类。如何做到这一点。
$(document).on('change', '#select-choice-1', function() {
var fontFamily = $(this).val() ;
var classesToChange = ".ui-body-c,.ui-btn-text,.ui-li-divider,.ui-header,.ui-li,.panel,.realtimeContend_h";
$(classesToChange).css("font-family", fontFamily);
});
<div data-role="fieldcontain">
<label for="text-12" style="text-align:left;margin-left: 0px;">Font Family:</label>
<select name="select-choice-1" id="select-choice-1">
<option>Select Font family</option>
<option value="AntiquaAntiqua">AntiquaAntiqua</option>
<option value="Arial">Arial </option>
<option value="Times New Roman">Times New Roman</option>
<option value="Corbel">Corbel</option>
<option value="Garamond">Garamond</option>
</select>
</div>
Div on other page
<div id="realTimeContents" class="realtimeContend_h">
sdsdfjdsjfkldf;gkd;sklfdfgkldlfg;ld;'gl'dlfgsjkkjkldl;sdf;dfs;;dsfkksdll;;sdkshfhsdfjsieiryidsmfnksdjf
sdsdfjdsjfkldf;gkd;sklfdfgkldlfg;ld;'gl'dlfgsjkkjkldl;sdf;dfs;;dsfkksdll;;sdkshfhsdfjsieiryidsmfnksdjf
sdsdfjdsjfkldf;gkd;sklfdfgkldlfg;ld;'gl'dlfgsjkkjkldl;sdf;dfs;;dsfkksdll;;sdkshfhsdfjsieiryidsmfnksdjf
sdsdfjdsjfkldf;gkd;sklfdfgkldlfg;ld;'gl'dlfgsjkkjkldl;sdf;dfs;;dsfkksdll;;sdkshfhsdfjsieiryidsmfnksdjf
sdsdfjdsjfkldf;gkd;sklfdfgkldlfg;ld;'gl'dlfgsjkkjkldl;sdf;dfs;;dsfkksdll;;sdkshfhsdfjsieiryidsmfnksdjf
</div>
$(document).on('change', '#select-choice-2', function() {
alert("dd")
var style;
var font = $(this).val();
if ($('head').find('style.font').length === 0) {
style = $('<style class="font">.font { font-size: ' + font + 'px !important; }</style>');
$('head').append(style);
$('body *').addClass('font');
} else {
$('body *').removeClass('font');
$('style.font').empty();
style = '.font { font-size: ' + font + 'px !important; }';
$('style.font').append(style);
}
});