Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

282
Views
I want to hide a ID when specific parameter is in URL (Javascript)

I want to hide an ID named #ko when a specific parameter is found in the url.

---Example---

For example this is the thank you page when a customer send a question:

https://website.nl/bedankt?k=Vraag&n1=Your%20Name&n2=&n3=

I want to hide id="ko" when k=Vraag is in the URL

But when the a customer asked for a quotation (k=Offerte) I want to show id="ko".

https://website.nl/bedankt?k=Offerte&n1=Your%20Name&n2=&n3=

This is the html:

<span style="color: #ffffff;">Ik heb je bericht in goede orde ontvangen en zal binnen 48 uur een reactie geven op je <span class="keuze">[get_param param="k"]</span><span id="ko"> aanvraag</span>.</span>

This is what I got right now, but it doesn't seem to work.

$(document).ready(function () {
   if (window.location.href.indexOf("k=Vraag") != -1) {
      $("#ko").hide();
   }
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Your code should work assuming jQuery is loaded (it was not) but I suggest you use searchParams and a toggle

$(function() {
  const url = new URL(window.location.href);
  const keuze = url.searchParams.get("k");
  $(".keuze").toggle(keuze === "" || keuze === "Vraag");
  $("#ko").toggle(keuze !== "Vraag" && keuze !== "Offerte");
});

Plain JS

window.addEventListener("load",function() {
  const url = new URL(window.location.href);
  const keuze = url.searchParams.get("k");
  document.querySelector(".keuze").hidden = keuze && keuze !== "Vraag";
  document.getElementById("ko").hidden = keuze === "Vraag" || keuze === "Offerte";
});

My second code after running the active code in the console shows

enter image description here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!