我就不吃芹菜

导航

 
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>test2</title>
        <link rel="stylesheet" type="text/css" href="res/layui/css/layui.css">
        <script type="text/javascript" src="res/layui/layui.js"></script>
    </head>
    <body>
        <div id="test-box">
            aaaaa
            <div>
                bbbbb
            </div>
        </div>

        <script type="text/javascript">
            layui.use(["layer"],function() {
                var layer = layui.layer;
                var $ = layui.jquery;

                var str = $('#test-box').contents().filter(function (index, content) {
                    console.log(index);
                    console.log(content);
                    return content.nodeType === 3;
                }).text();

                // alert($("#test-box").text());
                alert(str);
            });

        </script>
    </body>
</html>

 

posted on 2019-02-12 10:06  我就不吃芹菜  阅读(587)  评论(0编辑  收藏  举报