JavaScript實現(xiàn)點擊按鈕字體放大、縮小
更新時間:2016年02月29日 12:02:52 作者:rehcf
字體可以調節(jié)大小,極大了滿足了用戶體驗度,接下來通過本文給大家介紹JavaScript實現(xiàn)點擊按鈕字體放大、縮小實例代碼,需要的朋友參考下吧
本文給大家分享js實現(xiàn)點擊按鈕字體放大縮小實例代碼,代碼簡單易懂,需要的朋友參考下吧
具體代碼如下所示:
<style> .bb{color:red;} .cc{color:green;} .chapter {font-size: 1.5em;} .normal{font-size:12px;} .hidden{display:none;} </style> <script> $(document).ready(function() { $('div.aa').addClass('bb'); $('a[href^="http:"]').addClass('cc'); //$('#switcher-large').on('click',function(){ // $('div.large').addClass('chapter'); //}); $('#switcher-large').click(function(){ $('div.large').toggleClass('chapter'); $(this).toggleClass('bb'); }); //$('#switcher').click(function(){//點擊按鈕增加(移除)樣式(toggleClass方法) //$('#switcher button').toggleClass('hidden'); //}) //字體的放大縮小 var $biger = $('div.large'); var num = parseFloat($biger.css('fontSize')); $('#switcher-bigger').click(function(){ num=num*1.4; $biger.css('fontSize',num+'px'); }); $('#switcher-small').click(function(){ num=num/1.4; $biger.css('fontSize',num+'px'); }); }); </script> <div id="switcher" class="switcher"> <h3>Style Switcher</h3> <button id="switcher-default"> Default </button> <button id="switcher-hidden">Narrow hidden</button> <button id="switcher-large">Large Print</button> <button id="switcher-bigger">switcher-bigger</button> <button id="switcher-small">switcher-small</button> </div> <div class="large"> <p>腳本之家</p> <p>腳本之家</p> <p>腳本之家</p> <p>腳本之家</p> </div>
關于JavaScript實現(xiàn)點擊按鈕字體放大、縮小的相關知識就給大家介紹這么多,希望對大家有所幫助!
相關文章
Flutter 超實用簡單菜單彈出框 PopupMenuButton功能
這篇文章主要介紹了Flutter 超實用簡單菜單彈出框 PopupMenuButton功能,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-08-08firefox TBODY 用js顯示和隱藏時出現(xiàn)錯位的解決方法
今天幫別人寫一個網(wǎng)頁,發(fā)現(xiàn):當用javascript動態(tài)設置tr.style.display = "block"顯示某行時,使用IE瀏覽沒有問題,但使用firefox瀏覽時該行被移到了其它行的后面,很是詫異。2008-12-12