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

100
Views
Run cookies script only if checkbox contains class on page load

I have a cookies consent where I have categories like necessary cookies, adveritsing cookies, functional cookies etc.

What do I need to do is to run scripts once checkbox for category has class "jozo" (in this case its checked) on page load. But my script does not work.

On my HTML side its working like this:

<input type="checkbox" id="wt-cli-checkbox-advertisement" class="cli-user-preference-checkbox jozo" data-id="checkbox-advertisement" checked="checked">

Js side

if ($ ('input#wt-cli-checkbox-advertisement').hasClass('jozo')){
                $(document).ready(function() {
                        Facebook.loadPixel();
                        Analytics.loadPixel();
                        GAds.loadPixel(); 
                        });
                }

I need to also do that if it does not contain class "jozo" then run following script:

 Facebook.disable();
 Analytics.disable();
 GAds.disable();

This needs to be recognised on each page load. Now my scrips are not runing. They only run if I add this but then users can not turn them of in accord of the GDPR law.

$(document).ready(function() {
    Facebook.loadPixel();
    Analytics.loadPixel();
    GAds.loadPixel(); 
    });

Any ideas?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Maybe the checkbox loading after your script running. Convert it to:

$(document).ready(function() {
    if ($('input#wt-cli-checkbox-advertisement').hasClass('jozo')){
       Facebook.loadPixel();
       Analytics.loadPixel();
       GAds.loadPixel(); 
   }
   else {
       Facebook.disable();
       Analytics.disable();
       GAds.disable();
   }
});
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!