0

I have to re-create the following html element using Mootools

<input type="file" name="file[]" id="file" multiple />

for which I have used the following code

new Element('input', {
    'type': 'file',
    'id': 'file',
    'name': 'file[]',
    'multiple':''
});

Check the fiddle.

The issue is I cannot get the multiple attribute to be set in the element. How can I achieve setting an attribute without value (in this case, multiple) in a mootools element?

4

1 回答 1

4

multiple is a boolean attribute, so you can pass true as the value:

$('test').adopt(new Element('input', {
    'type': 'file',
    'id': 'file',
    'name': 'file[]',
    'multiple': true
}));
于 2013-04-26T09:30:42.467 回答