回车或是空格 浏览器都可能把他解释为文本节点,你可以用nodeType判断是什么节点,元素节点值为1,文本为3

解决方案 »

  1.   

    [iType=]object.nodeType
    iType 
    Integer that receives one of the following values.
    1 Element node. 
    3 Text node.  加个判断就行了
    L@_@K
    <!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> new document </title>
      <meta name="generator" content="editplus" />
      <meta name="author" content="" />
      <meta name="keywords" content="" />
      <meta name="description" content="" />
      <script type="text/javascript">
      <!--
    function getPreviousSiblingElementNode(oNode)
    {
    var oSiblingEle = oNode.previousSibling;
    while (oSiblingEle && oSiblingEle.nodeType != 1)
    {
    oSiblingEle = oSiblingEle.previousSibling;
    }
        return oSiblingEle;

      //-->
      </script>
     </head> <body>
    <input type="text" value="1">  <input onclick="alert(getPreviousSiblingElementNode(this).value)" type="radio" style="margin:5px 0;" > 
      
     </body>
    </html>