1<!DOCTYPE html>
2<html lang="en">
3<head>
4<meta charset="utf-8">
5<title>jQuery Adding Attribute to HTML Element</title>
6<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
7<script>
8 $(document).ready(function(){
9 $(".add-attr").click(function(){
10 $('input[type="checkbox"]').attr("checked", "checked");
11 });
12 });
13</script>
14</head>
15<body>
16 <button type="button" class="add-attr">Select Checkbox</button>
17 <input type="checkbox">
18</body>
19</html>