To do this, you can use the document.createElement() to create the script element and add it to the document. All these actions can be performed using the attr(), and removeAttr() jQuery methods.. Add attribute To add an attribute to a HTML element /or elements (any attribute, id, class, href, selected, etc. var weapons = { sords: true, guns: false, shield: true } var pro = 'arrows'; weapons.pro = true; console.log ( weapons.arrows ); // Output 'undefined'. JavaScript getAttribute () method. window.location) is a reference to a Location object; it represents the current URL of the document being displayed in that window. The example of using the .className property is given as follows.. We can use two approaches to modify an attribute of an HTML element using JavaScript. How to Set Dynamic Property Keys with ES6 . Input Text Object Properties. It is an interpreted programming language with object-oriented capabilities. Append these elements to the