Make Text as Searchable Query Automatically

Hey! you have an any one category’s website like song download, lyrics, software download and want to search word when add in span or paragraph tag. So follow simple steps and make entered word as searchable word.

How to Do

  • Add id between tag like <span id=”searchTerm1″> Antivirus </span> download for <p id=”searchTerm2″>PC </p>.
  • Then make button for search and add id.
    <button id=”searchable_text_btn”> Go </button>
  • And paste JavaScript on head/footer for this functionality.
function searchable_text_search() {
var term1 = document.getElementById("searchTerm1").textContent;
var term2 = document.getElementById("searchTerm2").textContent;
var query = "" + encodeURIComponent(term1) + "+" + encodeURIComponent(term2);
window.location.href = query;

var searchable_text_btn = document.getElementById("searchable_text_btn");
if(searchable_text_btn) {
searchable_text_btn.addEventListener("click", searchable_text_search);
  • Then SAVE and take Advantage.