Try It Editor
Tip: Press
Ctrl/⌘ + Enter
to Run
▶ Run
Reset
Copy
Download
Code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Visibility: :visible / :hidden</title> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <style>#box{width:120px;height:60px;background:#c8e6c9;margin:8px 0;} .hit{outline:2px solid #f44336;}</style> </head> <body> <div id="box"></div> <button id="toggle">Toggle</button> <button id="mark">Mark :hidden</button> <script> $("#toggle").click(function(){ $("#box").toggle(); }); $("#mark").click(function(){ $(":hidden").toggleClass("hit"); setTimeout(function(){ $(":hidden").removeClass("hit"); }, 600); }); </script> </body> </html>
Output