日期:2014-05-16  浏览次数:20528 次

菜鸟学做列表,但是提示错误?
<!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> Untitled   Page </title>
<script   language= "javascript "   type= "text/javascript ">
//   <!CDATA[

function   b1_ondblclick()   {
if(b1.innerText== "+ ")
{
b1.innerText= "- ";
list1.style.display= "block ";
}
else
{
b1.innerText== "+ "
list1.style.display= "none ";
}


}

//   ]]>
</script>
</head>
<body>
        <span   id=b1   onclick= "return   b1_onclick() "   style= "border-right:   thin   ridge;   border-top:   thin   ridge;   border-left:   thin   ridge;   border-bottom:   thin   ridge;   cursor:   hand; "> - </span> list1 <br   />
        <ul   id=list1>
                <li>
        item1 <br   /> </li>
        <li> item2 <br   /> </li>
        <li> item3 </li>
        </ul>
        list2

</body>
</html>


------解决方案--------------------


<!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> Untitled Page </title>
<script language= "javascript " type= "text/javascript ">
// <!CDATA[

function b1_ondblclick() {
if(b1.innerText== "+ "){
b1.innerText= "- ";
list1.style.display= "block ";
}
else
{
b1.innerText= "+ "//这个错误太低级了b1.innerText== "+ "
list1.style.display= "none ";
}
}

// ]]>
</script>
</head>
<body>
<span id=b1 onclick= "return b1_ondblclick() " style= "border-right: thin ridge; border-top: thin ridge; border-left: thin ridge; border-bottom: thin ridge; cursor: hand; "> - </span> list1 <br />
<ul id=list1>
<li>
item1 <br /> </li>
<li> item2 <br /> </li>
<li> item3 </li>
</ul>
list2

</body>
</html>

------解决方案--------------------
<!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> Untitled Page </title>
<script type= "text/javascript ">
// <!CDATA[

function b1_ondblclick()
{
var b1 = document.getElementByI