本文給大家分享js實(shí)現(xiàn)點(diǎn)擊按鈕字體放大縮小實(shí)例代碼,代碼簡(jiǎ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(){//點(diǎn)擊按鈕增加(移除)樣式(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>武林網(wǎng)</p><p>武林網(wǎng)</p><p>武林網(wǎng)</p><p>武林網(wǎng)</p></div>
關(guān)于JavaScript實(shí)現(xiàn)點(diǎn)擊按鈕字體放大、縮小的相關(guān)知識(shí)就給大家介紹這么多,希望對(duì)大家有所幫助!
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注