注册 登录
编程论坛 JavaScript论坛

按钮语句出了问题

colorlemon 发布于 2009-12-27 12:04, 585 次点击
作为一个初学者,问个问题是有很多压力的,已经不止一个人骂我了…………

这个东西不完全算是js程序……这只是我自己想的一个练习,就是鼠标指着按钮时按钮改变~但是又遇到可恶的问题……我知道我可能就是遇到了最不该遇到的愚蠢问题了,但我就是对着它看了1小时看不出问题所在~请好心的还记得自己初学时愚蠢样子的程序员们帮帮这个小忙吧,就当是扫盲好不?

程序代码:
<html>
<head>
<script language="JacaScript">
<!--
function changeButton(flag)
{
    var buttonObj=document.getElementById("myButton");
    if(flag==1)
    {
        buttonObj.style.backgroundColor = "lightBlue";
        buttonObj.style.color = "black";
        buttonObj.style.cursor = "pointer";
    }
    else
    {
        buttonObj.style.backgroundColor = "darkBlue";
        buttonObj.style.color = "white";
        buttonObj.style.cursor = "default";
    }
}
//-->
</script>

<style>
#myButton
{
    background-color:darkBlue;border:1px outset;color:white;
}
</style>

</head>

<body>
    <div style="margin-top:10px;">
        <input id = "myButton" type = "button" value = "check it"  onmouseover = "changeButton(1)" onmouseout = "changeButton(0)">
    </div>
</body>

</html>

3 回复
#2
aspic2009-12-27 15:23
程序代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www. xmlns="http://www. http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
#myButton{background-color:darkBlue; border:1px outset; color:white}
</style>
<script>
function changeButton(flag) {
    var obj = document.getElementById('myButton');
    if(flag == 1) {
        obj.style.backgroundColor = 'lightBlue';
        obj.style.color = 'black';
        obj.style.cursor = 'pointer';
    }else{
        obj.style.backgroundColor = 'darkBlue';
        obj.style.color = 'white';
        obj.style.cursor = 'default';
    }
}
</script>
</head>

<body>
<input type="button" id="myButton" value="check it" onmouseover="changeButton(1)" onmouseout="changeButton(0)" />
</body>
</html>
感觉没问题啊 你现在是什么问题啊
#3
aspic2009-12-27 15:28
最好用dw生成一个标准的文档
<html>
<head>
<script language="JacaScript"> 其实language可以不写的
直接<script></script>
#4
colorlemon2009-12-27 17:45
谢3楼,原来错在打字上这个纠结~

我看书上程序都写,以为和C++头文件一样了…………
1