Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0125· OpenAIAi2 WildChat-4.8M (AI2)

帮我写一个html工具,可以提取html中的文本

  1. User

    帮我写一个html工具,可以提取html中的文本

  2. Assistant
    <script>
        function extractText() {
            let htmlInput = document.getElementById('htmlInput').value;
            let tempDiv = document.createElement('div');
            tempDiv.innerHTML = htmlInput;
    
            let extractedText = tempDiv.textContent || tempDiv.innerText || '';
    
            document.getElementById('extractedText').innerText = extractedText;
        }
    </script>