scythargon
scythargon

Reputation: 3491

jquery detach(): [object Object] has no method 'replace'

Uncaught TypeError: Object [object Object] has no method 'replace' to be precise. The code:

var controls = $('#head_hidden').children().eq(0);
var item_mouse_over = function() {
    $(this).append(controls);
}
var item_mouse_leave = function() {
    $(this).detach(controls); //this is the problematic strig
}

$('.item').mouseover(item_mouse_over);
$('.item').mouseleave(item_mouse_leave);

Here is jsfiddle explanation. With item_mouse_over() I add "controls" to element, but with item_mouse_leave() I could not remove them:(

Upvotes: 1

Views: 1926

Answers (1)

zero
zero

Reputation: 3084

EDIT:::is this what you are attempting to do: http://jsfiddle.net/EhzFy/3/

if so then you have to remove the child from the div that it was added to:$(this).children().eq(0).detach();

but if all you're trying to accomplish is making the object move from one div to another then try this: http://jsfiddle.net/EhzFy/2/

Upvotes: 2

Related Questions