标签:color style node doctype link back utf-8 htm nbsp
<!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>
获取当前div中的文本(只获取当前div的, 子元素不要, 基于layui)
标签:color style node doctype link back utf-8 htm nbsp
原文地址:https://www.cnblogs.com/wgbs25673578/p/10364092.html