How js changes the font size of an article _ javascript skills

Source: Internet
Author: User
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";} script

Foot 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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.