<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>例子</title>
<script type="text/javascript">
<!-- 
function test(checked,txt){
    document.getElementById(txt).innerHTML = checked ? "no" : "yes";
}
//--> 
</script>
</head>
<body>
<input type="checkbox" onclick="test(this.checked,'txt')"/><label id="txt">yes</label>
</body>
</html>

解决方案 »

  1.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>例子</title>
    <script type="text/javascript">
    <!-- 
    function test(checkbox){
        checkbox.nextSibling.nodeValue = checkbox.checked ? "no" : "yes";
    }
    //--> 
    </script>
    </head>
    <body>
    <input type="checkbox" onclick="test(this)"/>yes
    </body>
    </html>