<td>sss<input type="hidden" value="aaa"/></td>怎么取sss

解决方案 »

  1.   


    <table>
        <tr>
            <td>sss<input type="hidden" value="aaa"/></td>
        </tr>
    </table>
    <script type="text/javascript">
        var textVal = $('td')[0].firstChild.nodeValue;
        console.log(textVal);
    </script>
      

  2.   

    <!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 src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    </head>
    <body>
        <table>
            <tr>
                <td>
                    sss<input type="hidden" value="aaa" />
                </td>
            </tr>
        </table>
        <script type="text/javascript">
            var textVal = $('td')[0].firstChild.nodeValue;
            alert(textVal.trim());
        </script>
    </body>
    </html>
      

  3.   

    js 里面没有console.log要用alert