Jacob George
Jacob George

Reputation: 2627

Setting an attribute without value for a mootools element

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?

Upvotes: 0

Views: 173

Answers (1)

Blender
Blender

Reputation: 298206

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
}));

Upvotes: 4

Related Questions