This article mainly introduces how js changes the font size of the Article. When you use Word documents, the toolbar provides you with the option to change the font size. How does js change the font size of the article, the following is an example of how many of your friends have asked questions:
How does js change the font size of an article?
I have read related articles and sorted out several small cases for your reference. The specific content is as follows:
:
Click the large or small buttons to change the font size at any time.
Code:
Use js to change the font size of an article Script function changesize (size) {document. getElementById ("article_content"). style. fontSize = size + "px";} scriptFoot home
Thank you!
Study hard every day
Big and small
To share with you the following example:
The working principle is very simple, that is, to change the font size of the article when the event is triggered. more straightforward, it is to change the font-size attribute value (jQuery version 1.7.2)
HTML
Zoom in and out by default
Here are some text
CSS
.box{text-align:center;}.ctrl{padding:50px 0px 0px 0px;background:#f4f4f4;font-size:0px;border-bottom:3px solid #333;}.ctrl a{display:inline-block;width:50px;height:30px;line-height:30px;background:#333;color:#fff;font-size:14px;}.ctrl a:hover{background:#444;color:#fff;font-weight:700;text-decoration:none;}.cont{padding-top:50px;font-size:14px;}
JS
$ (Function () {function sizeIn () {var sizeCont = parseInt ($ (". cont ").css (" fontSize "); // obtain the value of the original font-size if (sizeCont = 30) {// judge to stop when font-size increases to 30 pixels $ (". cont ").css ({fontSize: sizeCont});} else {$ (". cont ").css ({fontSize: sizeCont + 1}) ;}} function sizeOut () {var sizeCont = parseInt ($ (". cont ").css (" fontSize "); if (sizeCont = 10) {// stop when the font-size is reduced to 10 pixels (". cont ").css ({fontSize: sizeCont});} else {$ (". cont ").css ({fontSize: sizeCont-1}) ;}} function sizeDefault () {$ (". cont ").css ({fontSize:" "}) }$ (". ctrl "). click (function () {if ($ (this ). index () = 0) {sizeIn ();} else if ($ (this ). index () = 1) {sizeOut () ;}else {sizeDefault ();}})});
I hope this article will help you learn about javascript programming.