问答详情
源自:2-3 URL映射

我把老师的代码抄了一遍,不知道错在哪。

<html>

<head>

<title>hello</title>

<script>

function show_text(id,text)

{ document.getElementById(id).innerHTML=text;

}

function show_color(id,color)

{ document.getElementById(id).style.color=color;

}

</script>

<style>

div p { color : #f00 }

.py { font-size : 40px; }

#l1 { width : 200px; font-size:40ppx; }

</style>

</head>

<body>

<hl>hello</hl>

<div>World</div>

<p class="py">python</p>

<label id="l1">test</label>

<div>

<a href="javascript:void(0);" onclick=' javascript:show_text("l1","My First JavaScript");'>My First JavaScript</a>

<a href="javascript:void(0);" onclick=' javascript:show_text("l1","Hello python");'>Hello python</a>

<a href="javascript:void(0);" onclick=' javascript:show_text("l1","#0f0");'>green</a>

<a href="javascript:void(0);" onclick=' javascript:show_text("l1","#f00";'>red</a>

</div>

</body>

</html>


提问者:qq_vocaloid第一3361037 2017-07-05 15:45

个回答

  • 宝慕林6387091
    2017-07-07 16:03:41
    已采纳

    你这个copy错了:

    <a href="javascript:void(0);" onclick=' javascript:show_color("l1","#0f0");'>green</a>

    <a href="javascript:void(0);" onclick=' javascript:show_color("l1","#f00");'>red</a>