Change css font-family for separate options in select tag

后端 未结 7 2037
傲寒
傲寒 2020-12-02 00:05

I don\'t know if this is possible, and if not, if someone can throw out optional ideas, but I\'m attempting to display a drop down of different fonts (specifically, font\'s

7条回答
  •  借酒劲吻你
    2020-12-02 00:37

    Give the font name to option value. Then you can set them all with jquery.

    Here is an example:

    You can add new font easily like this:

    
    

    $("#selectfont").each(function(){
      $(this).children("option").each(function(){
        $(this).css("fontFamily",this.value);
      });
    });
    
    

提交回复
热议问题