允许用户编辑字体系列

Allowing users to edit font family

本文关键字:编辑 字体 系列 用户 许用户      更新时间:2023-09-26

如何允许我的网站用户编辑字体系列?

我想要一个可以更改网站字体的页面下拉列表。它应该立即发生,如果可能的话,不需要点击按钮。

我该怎么做?

改进-试试这个小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>

您可以使用jQuery轻松做到这一点:

$("body").css("font-family","Arial");