In addition to Weibo, there is also WeChat
Please pay attention

WeChat public account
Shulou
2025-10-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "how to use javascript to set font size", the content of the article is simple and clear, easy to learn and understand, now please follow the editor's ideas slowly in depth, together to study and learn "how to use javascript to set font size" bar!
Javascript set font size method: 1, create "function setFontSize (id,content,params) {...}" method; 2, through "setFontSize (id,contentid, {...})" method debugging.
This article operating environment: windows7 system, javascript1.8.5 version, Dell G3 computer.
How does javascript set the font size?
The method of controlling font size setting by JavaScript
When working on the company's official website, the inside page of the news will have a feature that allows the viewer to resize the text, so sort out this function in this free time:
Function setFontSize (id,content,params) {var oTarget = document.getElementById (id), content = document.getElementById (content), size = params.size | | 14, maxSize = params.maxSize | | 20, step = params.step | | 2; oBtn =''; oBtn1 = null, oBtn2 = null; oTarge [XSS _ clean] = oBtn; oBtn1 = oTarget.childNodes [0] OBtn2 = oTarget.childNodes [1]; oBtn1.onclick=function () {if (size+step = 12) {size-=step;} else {size = 12; this.className+=' disabled' this.disabled = true;} oBtn1.className.replace ('disabled',''); oBtn1.disabled = false Content.style.fontSize = size + 'px';}}
Call method:
SetFontSize (id,contentid, {size:,maxSize,step:}); / * * id: the id used to store the parent box that adds or decreases two buttons. * contentid: the id where the content is stored. * {} an object that provides set parameters. |-szie: font start size (default). |-maxSize: the largest font. |-step: the step size of growth. , /
Tip: you can hide the value of the Input element through font-size:0, and then customize the style of the button.
Thank you for your reading, the above is the content of "how to set font size with javascript". After the study of this article, I believe you have a deeper understanding of how to use javascript to set font size, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope





About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.