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

Jquery 取文本问题.
HTML code

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


怎么取sss

------解决方案--------------------
HTML code
<!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>