注册 登录
编程论坛 WEB前端(UI)

Web新手求教 我这代码为什么没有反应

R的补 发布于 2019-04-01 18:52, 10977 次点击
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
    #div{
        border:solid 1px #0033FF;
        width:550px;
        padding:20px;
    }
    #text{
        margin-top:20px;
    }
    #cfdiv{
        text-align: right;
        /*调整宽度*/
        width: 400px;
    }
    #cfdiv a:link,a:visited {
        color:#0033FF;
        text-decoration:none;
    }
    #cfdiv a:hover{
        color:#FF6633;
    }
</style>
<script type="text/javascript" src="jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $("a.#G").click(function(){
            var divNode = document.getElementById("text");
                divNode.style.fontSize=Font_Size[0].GREAT+"px";
        }
        $("a.#M").click(function(){
            var divNode = document.getElementById("text");
            divNode.style.fontSize=Font_Size[1].MEDIUM+"px";
        }
        $("a.#S").click(function(){
            var divNode = document.getElementById("text");
            divNode.style.fontSize=Font_Size[2].SMALL+"px";
        }
        var Font_Size= [
            {GREAT:18},
            {MEDIUM:16},
            {SMALL:12}
        ];
    }
</script>

</head>
<body>
    <div id="div">
        <div id=“title”>
            <h1>Web程序设计</h1><hr/>
        </div>
        <div id="cfdiv">
            <a href="javascript:void(0)" id="G">大字体</a>
            <a href="javascript:void(0)" id="M">中字体</a>
            <a href="javascript:void(0)" id="S">小字体</a>
        </div>
        <div id="text">
            HTML CSS DOM JAVASCRIPT JQUERY<br />
        </div>
    </div>
</body>
</html>
12 回复
#2
R的补2019-04-01 18:52
求大佬指点
#3
R的补2019-04-02 09:05
有人吗?。。
#4
R的补2019-04-02 15:37
这个板块是真的偏僻,失望~~
#5
醉仙不醉2019-04-22 20:02
回复 楼主 R的补
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    <style type="text/css">
        #div{
            border:solid 1px #0033FF;
            width:550px;
            padding:20px;
        }
        #text{
            margin-top:20px;
        }
        #cfdiv{
            text-align: right;
            /*调整宽度*/
            width: 400px;
        }
        #cfdiv a:link,a:visited {
            color:#0033FF;
            text-decoration:none;
        }
        #cfdiv a:hover{
            color:#FF6633;
        }
    </style>
    <script type="text/javascript" src="jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $("#G").click(function(){
                var divNode = document.getElementById("text");
                divNode.style.fontSize=Font_Size[0].GREAT+"px";
            })
            $("#M").click(function(){
                var divNode = document.getElementById("text");
                divNode.style.fontSize=Font_Size[1].MEDIUM+"px";
            })
            $("#S").click(function(){
                var divNode = document.getElementById("text");
                divNode.style.fontSize=Font_Size[2].SMALL+"px";
            })
            var Font_Size= [
                {GREAT:18},
                {MEDIUM:16},
                {SMALL:12}
            ];
        })
    </script>

</head>
<body>
<div id="div">
    <div id=“title”>
        <h1>Web程序设计</h1><hr/>
    </div>
    <div id="cfdiv">
        <a href="javascript:void(0)" id="G">大字体</a>
        <a href="javascript:void(0)" id="M">中字体</a>
        <a href="javascript:void(0)" id="S">小字体</a>
    </div>
    <div id="text">
        HTML CSS DOM JAVASCRIPT JQUERY<br />
    </div>
</div>
</body>
</html>
#6
奋斗中的小蟹2019-05-11 08:59
是可以运行的,你换个浏览器试试
#7
Binhun2019-06-06 15:31
#8
wcx112019-06-11 16:29
有人肯定是有人,只是回复不会那么快罢了
#9
z11517280422019-07-03 17:40
把脚本放到最后面就行了
#10
星系隐2019-11-03 23:09
我试了一下,感觉我离各位大哥的水平还差得很远..

[此贴子已经被作者于2019-11-3 23:10编辑过]

#11
搞钱2021-01-21 18:57
<script type="text/javascript" src="jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $("a.#G").click(function(){
            var divNode = document.getElementById("text");
                divNode.style.fontSize=Font_Size[0].GREAT+"px";
        }
        $("a.#M").click(function(){
            var divNode = document.getElementById("text");
            divNode.style.fontSize=Font_Size[1].MEDIUM+"px";
        }
        $("a.#S").click(function(){
            var divNode = document.getElementById("text");
            divNode.style.fontSize=Font_Size[2].SMALL+"px";
        }
        var Font_Size= [
            {GREAT:18},
            {MEDIUM:16},
            {SMALL:12}
        ];
    }
</script>
它放在div后面
#12
agnes_l2021-02-22 16:26
<script type="text/javascript">
        $(document).ready(function(){
            $("#G").click(function(){
                var divNode = document.getElementById("text");
                divNode.style.fontSize=Font_Size[0].GREAT+"px";
            })
            $("#M").click(function(){
                var divNode = document.getElementById("text");
                divNode.style.fontSize=Font_Size[1].MEDIUM+"px";
            })
            $("#S").click(function(){
                var divNode = document.getElementById("text");
                divNode.style.fontSize=Font_Size[2].SMALL+"px";
            })
            var Font_Size= [
                {GREAT:18},
                {MEDIUM:16},
                {SMALL:12}
            ];
        })
    </script>
加上括号就行
#13
搞钱2021-04-29 22:03
缺少括号
1