Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery Set Element's Attribute Value</title> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ $('input[type="checkbox"]').attr("checked", "checked"); }); }); </script> </head> <body> <p><label><input type="checkbox"></label> I agree with terms and conditions.</p> <button type="button">Check</button> </body> </html>