From 21f600270f4d2dbaed355b3521221c4ffc135d90 Mon Sep 17 00:00:00 2001 From: liangjiami <2249412933@qq.com> Date: Thu, 17 Jul 2025 16:49:03 +0800 Subject: [PATCH] 1 --- .../view/mobile/topic_nas/help_detail.html | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/app/index/view/mobile/topic_nas/help_detail.html b/app/index/view/mobile/topic_nas/help_detail.html index 4ca4890d..ae867184 100644 --- a/app/index/view/mobile/topic_nas/help_detail.html +++ b/app/index/view/mobile/topic_nas/help_detail.html @@ -183,12 +183,26 @@ 'white-space': 'normal', }); - // 处理文本节点 - $('#rendered-content').find('*').contents().filter(function() { - return this.nodeType === 3; - }).each(function() { - $(this).replaceWith(this.nodeValue.replace(/ /g, ' ')); - }); + // 处理函数 + function processTextNodes($element) { + $element.contents().each(function() { + if (this.nodeType === 3) { // 文本节点 + let $parent = $(this).parent(); + let cleanHtml = $parent.html() + .replace(/<[^>]+>/g, '') // 移除所有标签 + .replace(/\s/g, ''); // 移除所有空白 + + if (cleanHtml !== ' ') { + $(this).replaceWith(this.nodeValue.replace(/ /g, ' ')); + } + } else if (this.nodeType === 1) { // 元素节点 + processTextNodes($(this)); + } + }); + } + + // 执行处理 + processTextNodes($('#rendered-content')); }); {/block} \ No newline at end of file