Traffic Signal Source Code in JQuery
Lets see the Traffic Signal Source Code in JQuery .
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
<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