Traffic Signal Source Code in JQuery
Lets see the Traffic Signal Source Code in JQuery .
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("#red").click(function(){ $("#div1").fadeIn(); }); $("#yellow").click(function(){ $("#div2").fadeIn("slow"); }); $("#green").click(function(){ $("#div3").fadeIn("slow"); }); }); $(document).ready(function(){ $("#red").click(function(){ $("#div2").hide(); $("#div3").hide(); }); $("#yellow").click(function(){ $("#div1").hide(); $("#div3").hide(); }); $("#green").click(function(){ $("#div1").hide(); $("#div2").hide(); }); }); </script> </head> <body> <p>Traffic Signal Demonstration with JQuery </p> <button id ="red">Signal is oFF for Traffic </button> <br><br> <button id= "yellow">Ready to on the traffic </button> <br><br> <button id= "green">Signal is on for Traffic </button> <br><br> <div id="div1" style="width:80px;height:80px;display:none;background-color:red; border-radius:50%;"></div><br> <div id="div2" style="width:80px;height:80px;display:none;background-color:yellow; border-radius:50%;"></div><br> <div id="div3" style="width:80px;height:80px;display:none;background-color:green; border-radius:50%;"></div> </body> </html>
Output