"page load" append event

1

In this code snippet, div1 is placed in div2 when you click on it, but I wanted it to be done automatically when loading the page without having to click on it.

I've tried replacing the .click event with .load or .ready but it does not.

jQuery(function ($) {

    $('#DIV1').click(function () {

        $('#DIV2').append(this);

    });  
});
    
asked by anonymous 27.05.2014 / 22:53

1 answer

1

You should do this:

jQuery(function ($) {
    $('#DIV2').append($('#DIV1'));
});

In the code you had, this was a pointer to the clicked element, that is $('#DIV1') . And when the click appeared the div2 received append this .

    
27.05.2014 / 23:18