My link is a form...
✓ Published0🌍 Public
Aabernier
Last edited Feb 7, 2011
Created on Feb 7, 2011
This example shows a GitHub pull request close button that submits the form directly via JavaScript instead of relying on a normal link navigation. The HTML anchor contains an inline `onclick` handler that dynamically creates a form element, sets its method to `POST`, assigns the link’s `href` as the action, and appends a hidden input carrying an authenticity token. The code uses the native DOM APIs `document.createElement`, `appendChild`, and `form.submit()` to perform the submission, preventing the default link behavior by returning `false`. No external libraries are involved; the rendering is plain HTML and CSS.
AI-generated description