<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<SCRIPT LANGUAGE="JavaScript">
function changebg(colorvalue){
document.bgColor=colorvalue;
}
</SCRIPT>
</HEAD><BODY id="bName" name="bbname" bgcolor="#ffffff" border="1">
<input type=button name="b" value="变蓝色" onclick="changebg('blue')">
<input type=button name="b" value="变红色" onclick="changebg('red')">
</BODY>
</HTML>

解决方案 »

  1.   


    <script>function setbg()
    {
    table1.bgColor="yellow";
    button1.bgColor="red";
    }
    </script>
    <table width="98%" border="0" align="center"  name="table1">
      </table>
    <type="button" name="button1" onclick='setbg()'>
      

  2.   

    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    class myframe extends Frame
    {
       Button b;
       public static void main(string args[])
        {
          myframe=new myframe();
        }
       public myframe()
        {
           super("windows title");
           b1=new Button("click here");
           add("center",b1);
           ButtonListener bl=new ButtonListener();
           b1.addActionListener(bl);
           setVisible(true);
           setSize(200,200);
       }
       class ButtonListener implements ActionListener
       {
            public void actionPerformed(ActionEvent e)
            {
                 Button soure=(Button)e.getSoure();
                 soure.setLabel("Button clicked!");
             }
       }
    }
    应该就是这个了 ~换背景也和这个岔不多
      

  3.   

    等等!我写的程序里面b和b1打错了~晕~乱了套了~你看玩自己改改啊~
    定义button是b 监听是b1