The implementation of jquery page font size becomes larger and smaller

Source: Internet
Author: User

Reprint please indicate, http://www.gxabase.com

jquery's implementation of the font becomes larger, smaller, which is often used when we do the Web page features, the following is the implementation process:

1. Make page index.html, page code is as follows:

<!DOCTYPE HTML>  <HTMLLang= "en">      <Head>        <MetaCharSet= "UTF-8"/>        <title>JQuery Training</title>      </Head>      <Body><p>font Size:<ahref="#"ID= "smaller">Smaller</a><ahref="#"ID= "bigger">Bigger</a><BR/></p>         <P>This is a Paragraph.</P>        <Scripttype= "Text/javascript"src= "Js/jquery.js"></Script><!--Download the Jquery_xxx.js file in the http://www.jquery.org Web site and import this page-<Scripttype= "Text/javascript"src= "Js/ext.js"></Script><!--Custom JS files--      </Body>  </HTML>

2. Write the contents of the Ext.js file in JS directory as follows:

functionchange_size (element,size) {varCurrent = parseint (Element.css (' font-size '))); //alert (current);    if(size = = "smaller"){        varNewSize = Current-2; }Else if(Size = = "bigger"){        varNewSize = current + 2; } element.css (' Font-size ', newsize+ ' px ');} $("#smaller"). Click (function() {change_size ($ ("P"), "smaller"); });$("#bigger"). Click (function() {change_size ($ ("P"), "bigger"); });

The ability to change the font size of a paragraph can be achieved through the above two steps.

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.