Run
Reset
Chrome
Cobalt
Monokai
Dreamweaver
Vibrant Ink
<!DOCTYPE html> <html> <head> <title>Learning jQuery</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script> </head> <body> <button>Click to fade circles</button> <div id="div1"></div> <div id="div2"></div> </body> </html>
div{ width: 80px; height: 80px; border-radius: 50%; } #div1{ background-color: black; } #div2{ background-color: purple; }
$(document).ready(function(){ $("button").click(function(){ $("#div1").fadeTo("slow", 0.1); $("#div2").fadeTo("slow", 0.5); }); });