Reputation: 2074
I'm trying to disable all form elements by a div, so I tried as following:
var form = elt.find("form:first-child");
// Disable all form elements
form.css('display','relative');
var lightBox = $('div');
lightBox.css({
'display': 'absolute',
'top': '0',
'right': '0',
'bottom': '0',
'left': '0'
});
form.append(lightBox);
But I get this error message:
Failed to execute 'appendChild' on 'Node': The new child element contains the parent.
How can I solve this?
Upvotes: 1
Views: 2290
Reputation: 92471
$('div')
selects all divs. If you want to create a div, you should use $('<div>')
instead.
var form = elt.find("form:first-child");
// Disable all form elements
form.css('display','relative');
var lightBox = $('<div>');
lightBox.css({
'display': 'absolute',
'top': '0',
'right': '0',
'bottom': '0',
'left': '0'
});
form.append(lightBox);
Upvotes: 4