<div class="js-text">test<span>subtest</span></div> <script type="text/javascript"> $(function(){ var text = $('.js-text').contents()[0].data; console.log(text); //输出test }); </script>