{"id":1498,"date":"2023-02-17T04:11:17","date_gmt":"2023-02-17T04:11:17","guid":{"rendered":"https:\/\/www.tools.keywordfinder.us\/?page_id=1498"},"modified":"2023-02-17T04:11:17","modified_gmt":"2023-02-17T04:11:17","slug":"text-keyword-density","status":"publish","type":"page","link":"https:\/\/tools.billionsideas.com\/de\/text-keyword-density\/","title":{"rendered":"Text Keyword Density"},"content":{"rendered":"<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column has-base-3-background-color has-background is-layout-flow wp-block-column-is-layout-flow\">\n<section><h1>Keyword Density Checker<\/h1>\n    <link rel=\"stylesheet\" type=\"text\/css\" href=\"checkDensity.css\">\n    <div class=\"container\">\n        <center><form action=\"\">\n            <label for=\"text\"><b>Enter Text<\/b><\/label><br>\n            <textarea id=\"text\"><\/textarea><br>\n            <label for=\"keyword\"><b>Enter Keyword<\/b><\/label><br>\n            <input type=\"text\" id=\"keyword\">\n            <button type=\"button\" onclick=\"checkDensity()\">Check Density<\/button><br><br>\n        <input type=\"hidden\" name=\"trp-form-language\" value=\"de\"\/><\/form><\/center>\n        <div id=\"response\"><\/div>\n    <\/div>\n    <script src=\"checkDensity.js\"><\/script>\n<\/section>\n\n<style>\n\n#response {\n    margin-top: 20px;\n    font-size: 1.2em;\n}\n\n.error {\n    color: red;\n}\n\n.density {\n    font-weight: bold;\n    color: green;\n}\n\n.highlight {\n    background-color: yellow;\n}\n\n<\/style>\n\n<script>\nfunction checkDensity() {\n  const text = document.getElementById('text').value;\n  const keyword = document.getElementById('keyword').value;\n  const responseDiv = document.getElementById('response');\n\n  if (!text || !keyword) {\n    responseDiv.innerHTML = '<p class=\"error\">Please enter both text and keyword<\/p>';\n    return;\n  }\n\n  \/\/ Count the number of times the keyword appears in the text\n  const keywordRegex = new RegExp(`\\\\b${keyword}\\\\b`, 'gi');\n  const keywordCount = (text.match(keywordRegex) || []).length;\n\n  \/\/ Calculate the density of the keyword\n  const density = (keywordCount \/ text.split(' ').length) * 100;\n\n  \/\/ Display the density percentage\n  responseDiv.innerHTML = `<p>Keyword density: <span class=\"density\">${density.toFixed(2)}%<\/span><\/p>`;\n\n  \/\/ Highlight the keyword in the text\n  const highlightedText = text.replace(keywordRegex, `<span class=\"highlight\">${keyword}<\/span>`);\n  document.getElementById('text').innerHTML = highlightedText;\n}\n\n<\/script>\n<hr>\n\n<style>\nsection{\n         margin-top:60px;\n        width: 100%;\n        max-width: 970px;\n        background-color: #fff;\n        border: 1px solid #ddd;\n        padding: 25px;\n      }\n<\/style>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Keyword Density Checker Enter Text Enter Keyword Check Density<\/p>","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_kad_blocks_custom_css":"","_kad_blocks_head_custom_js":"","_kad_blocks_body_custom_js":"","_kad_blocks_footer_custom_js":"","footnotes":""},"class_list":["post-1498","page","type-page","status-publish"],"taxonomy_info":[],"featured_image_src_large":false,"author_info":{"display_name":"Billions Ideas","author_link":"https:\/\/tools.billionsideas.com\/de\/author\/loginbillionsideas-com\/"},"comment_info":0,"jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/tools.billionsideas.com\/de\/wp-json\/wp\/v2\/pages\/1498","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tools.billionsideas.com\/de\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/tools.billionsideas.com\/de\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/tools.billionsideas.com\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tools.billionsideas.com\/de\/wp-json\/wp\/v2\/comments?post=1498"}],"version-history":[{"count":0,"href":"https:\/\/tools.billionsideas.com\/de\/wp-json\/wp\/v2\/pages\/1498\/revisions"}],"wp:attachment":[{"href":"https:\/\/tools.billionsideas.com\/de\/wp-json\/wp\/v2\/media?parent=1498"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}