javascript弱智问题

来源:百度知道 编辑:UC知道 时间:2024/05/31 22:17:22
"this is my element" 这句话的背景为什么没有变成红色?我使用id的语法对不对啊?

<html>
<head>
<style type=text/javascript>

#myelement{
background-color:red
}

</style>
</head>
<body>
<div id="myelement"> This is my element.</div>

</body>

</html>

你用的是css的语法啊

改成这样就对了

<html>
<head>
<style type="text/css">
#myelement{
background-color:red
}

</style>
</head>
<body>
<div id="myelement"> This is my element.</div>

</body>

</html>

文字的颜色,用"color"属性,不是背景

语法错误

这个不是javascript的问题,应该将<style type=text/javascript>
改为<style type='text/css'>

<div class="myelement"> This is my element.</div>