This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
http://dom.spec.whatwg.org/#dom-document-createattribute [[ createAttribute ]] http://dom.spec.whatwg.org/#dom-element-setattributenode [[ setAttributeNode ]] There is no alternate method provided for setting an attribute with no value. For example, the only way to set the checked, selected or disabled attribute with no value is with element.setAttributeNode( document.createAttribute( 'selected' ) ); The behavior is subtly different then setting the element property as element.selected = true; because the attribute persists when a form is reset.
What's wrong with setAttribute("selected", "")?
Nothing.
The property for selected="" is defaultSelected, not selected.