Closed
Bug 265543
Opened 20 years ago
Closed 20 years ago
setAttribute("className", "form-field-border") will not set that style
Categories
(Core :: DOM: Core & HTML, defect)
Tracking
()
RESOLVED
INVALID
People
(Reporter: chruker, Unassigned)
Details
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.1) Gecko/20040707
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.1) Gecko/20040707
This code for adding a file browsing input field to a form, doesn't set the style:
function add_file_upload() {
oFileList = document.getElementsByName("FileList").item(0);
// Create elements
input = document.createElement("input");
br = document.createElement("br");
// Set attributes
input.setAttribute("type", "file");
input.setAttribute("size", "80");
input.setAttribute("name", "uploaded_file[]");
input.setAttribute("className", "form-field-border form-field-colored
form-field-text");
// input.setAttribute("class", "form-field-border form-field-colored
form-field-text");
//debug_dom_object(input);
// Attach them to the document tree
oFileList.appendChild(input);
oFileList.appendChild(br);
}
However when changing the code to set 'class' instead of 'className' the style
is used.
Reproducible: Always
Steps to Reproduce:
Comment 1•20 years ago
|
||
The attribute is called "class". "className" is the name of the _property_.
Doing |foo.className = "whatever"| is equivalent to
|foo.setAttribute("class", "whatever")|. The reason you can't do foo.class is
that "class" is a reserved word in many languages.
I know IE gets this all wrong, but that's IE's problem, really.
Marking invalid. What we're doing is the right thing.Status: UNCONFIRMED → RESOLVED
Closed: 20 years ago
Resolution: --- → INVALID
You need to log in
before you can comment on or make changes to this bug.
Description
•