首页 > Web开发 > 详细

jQuery——修改网页字体大小

时间:2017-07-06 00:17:35      阅读:399      评论:0      收藏:0      [点我收藏+]

HTML:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <link type="text/css" href="09.css" rel="stylesheet"/>
        <script type="text/javascript" src="jquery.js"></script>
        <title></title>
    </head>
    <body>
        <h1>wo men</h1>
        <p>cfjdsmc edvc ewrd csd wrvc d  2e34efrew8r934efc cred  ewfced
        vefwid cfer fd 3ew fcxdwdkjfdke fewf dewkdse fcedwfewdfcs
        fre dfc ed fcejfoklew ferf
        defedefcd</p>
        <input type="button" id="big" value="放大"/><br />
        <input type="button" id="small" value="缩小"/>
        <script type="text/javascript">
            $("input").click(function(){
                var t = $("p").css("font-size")
                var t1 = parseInt(t, 10)
                var unit = t.slice(-2)
                var name1 = $(this).attr("id")
                if(name1 == "big"){
                    t1 += 2
                }
                else if(name1 == "small"){
                    t1 -= 2
                }
                $("p").css("font-size", t1+unit)
            })
        </script>
    </body>
</html>

END

jQuery——修改网页字体大小

原文:http://www.cnblogs.com/sunshine-blog/p/7124097.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!