javascript - How do I hide a opt-in script from logged in users? -


i run membership site , have script shows opt-in pop form after visitors on page more 10 seconds. however, pop-up shows public uses our paid members.

how can wrap pop-up <script> in custom javascript code detect presence of "logged-in" body class? if found, script should not fire.

if (document.queryselectorall('.logged-in').length) {     // worst (here) } 

you can use queryselectorall function search dom object on page. , if exists run code.


might better though have backend handle part , load js logged in users when user actually logged in


Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -