jQuery / JS / 前端技術 / 筆記 · 2019-10-21

jQuery Textsize 切換網頁文字尺寸

控制網頁文字大小

<script type="text/javascript">
     function MM_changeProp(objId,x,theProp,theValue) { //v9.0
       var obj = null; with (document){ if (getElementById)
       obj = getElementById(objId); }
       if (obj){
          if (theValue == true || theValue == false)
            eval("obj.style."+theProp+"="+theValue);
          else eval("obj.style."+theProp+"='"+theValue+"'");
       }
     }
</script>
<ul>
    <li id="max" onclick="MM_changeProp('con','','fontSize','1.6em','DIV')">巨</li>
    <li id="big" onclick="MM_changeProp('con','','fontSize','1.4em','DIV')">大</li>
    <li id="middle" onclick="MM_changeProp('con','','fontSize','1.2em','DIV')">中</li>
    <li id="small" onclick="MM_changeProp('con','','fontSize','1em','DIV')">小</li>
</ul>

<div id="con">
    預變化文字區塊
</div>