Javascript examples for jQuery:CSS
The following example will set a background-color and a font-size for ALL matched elements:
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $("p").css({"background-color": "yellow", "font-size": "200%"}); });/* w w w . ja v a 2 s . com*/ }); </script> </head> <body> <h2>This is a heading</h2> <p style="background-color:#ff0000">This is a paragraph.</p> <p style="background-color:#00ff00">This is a paragraph.</p> <p style="background-color:#0000ff">This is a paragraph.</p> <p>This is a paragraph.</p> <button>Set multiple styles for p</button> </body> </html>