How to add attributes to an HTML element using jQuery

Complete Program for adding required attribute, and setting some value in html element using jQuery. <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”utf-8″> <title>Adding Attribute to HTML Element Using jQuery</title> <script src=”https://code.jquery.com/jquery-1.12.4.min.js”></script> <script> $(document).ready(function(){ $(“.add-attribute”).click(function(){ // Setting Checkbox is checked $(‘input[type=”checkbox”]’).attr(“checked”, “checked”); // Setting a test value in textbox $(‘input[type=”text”]’).attr(“value”, “My Name is Shailendra”); }); }); […]