MDN self-hosted library · e01.org

HTMLFormElement: method property

HTML DOM

Open notebook · 1 cells web-api-instance-property upstream source

HTML DOM

The HTMLFormElement.method property represents the HTTP method used to submit the form.

Unless explicitly specified, the default method is 'get'.

Value

A string.

Examples

document.forms["my-form"].method = "post";

const formElement = document.createElement("form"); // Create a form
document.body.appendChild(formElement);
console.log(formElement.method); // 'get'

Specifications

Browser compatibility