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

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

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

asp.net mvc - breakpoint on javascript in CSHTML? -