javaScript字体变大

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
    <script type="text/javascript">
        function fun(){
            //1.拿到p标签对象
            var p=document.getElementById("p");
            //2.拿到p标签对象的主体内容   ,innerHTML必须是有开始标签和结束的标签对象才能使用
            var txt=p.innerHTML;
            //3.改变字体内容,再赋值回去
            p.innerHTML=txt.big();
        }
    </script>
<body>
    <p id="p">变大</p>
    <button onclick="fun()">点我变大</button>
    <!-- <input type="button" value="点我变大"onclick="fun()"> -->
</body>

</html>


猜你喜欢

转载自blog.csdn.net/hnwolfs/article/details/50888374
今日推荐