/

HTML / CSS / JavaScript Tutorial

JavaScript DOM HTML method: setAttribute()

[this page | pdf | back links]

The setAttribute() method (when applied to HTML elements in the JavaScript DOM) sets the specified attribute value.

 

It has the following syntax with the following parameters. It does not return a value.

 

element.setAttribute(attributename, attributevalue)

 

Parameter

Required / Optional

Description

attributename

Required

String indicating name of attribute to be set

attributevalue

Required

String indicating value of that attribute

 


NAVIGATION LINKS
Contents | Prev | Next | JavaScript DOM (and BOM)


Desktop view | Switch to Mobile