简体   繁体   中英

Change font-family using jQuery

I want to change the font-family of a string embedded inside a function of jQuery. I have tried every means without luck. Please help me. Here is the code:

$(function() {
  $(".element").typed({
    strings: ["Web/Graphic Designer"],
    typeSpeed: 70,
    showCursor: false,
  });
});

The font-family: 'HelveticaLTStd-Roman' but I can't change it to my preferred font. All help will be appreciated. Thanks.

You can do something like this. Adding .css() for adding the specific font on your selected elements.

$(function() {
  $(".element").typed({
    strings: ["Web/Graphic Designer"],
    typeSpeed: 70,
    showCursor: false,
  }).css("font-family", "HelveticaLTStd-Roman");
});

Here is jQuery's offical documentation on .css http://api.jquery.com/css/

Don't forget to include the font to your project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM