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.