Try It Editor
Tip: Press
Ctrl/⌘ + Enter
to Run
▶ Run
Reset
Copy
Download
Code
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>css() get/set multiple</title> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <style>#box{width:80px;height:80px;background:#bbdefb;border:4px solid #64b5f6}</style> </head> <body> <div id="box"></div> <p> <button id="get">get css('border-width')</button> <button id="set">set multiple css</button> </p> <pre id="out"></pre> <script> $("#get").on("click", function(){ $("#out").text($("#box").css("border-width")); }); $("#set").on("click", function(){ $("#box").css({ width:120, height:60, background:"#c8e6c9", borderColor:"#81c784" }); }); </script> </body> </html>
Output