如何允许我网站的用户编辑字体系列?
我想要一个可以更改网站字体的页面上的下拉菜单。它应该立即发生,如果可能的话不需要单击按钮。
我该怎么做?
最佳答案
改进 - 尝试这个小 jQuery
<html>
<head><title>Test</title></head>
<body style="font-family: Helvetica;">
<select name="ListMenuId" id="ListMenuId">
<option value="">Change this</option>
<option value="1">This change the font family to Verdana</option>
</select>
<select name="ListMenu2" id="ListMenu2">
<option value="">Change for selected font-family</option>
<option value="Verdana">This change the font family to Verdana</option>
<option value="Arial">This change the font family to Arial</option>
<option value="Helvetica">This change the font family to Helvetica</option>
<option value="Times New Roman">This change the font family to Times New Roman</option>
</select>
</body>
<script type="text/javascript">
$(function(){
$('#ListMenuId').change(function(){
$('body').css('font-family', 'Verdana'); // Specific font-family
});
$('#ListMenu2').change(function(){
$('body').css('font-family', $(this).val()); // Gets font-family from list menu option value
});
});
</script>
</html>
关于javascript - 允许用户编辑字体系列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23226779/