Faery
Faery

Reputation: 4650

Can I show an element in a specific div - jQuery

I have an element, which I need to be in a for cycle in the middle of the page, so that it can be populated with the right information. This aside element is hidden. On hoven, however it should appear. The problem is that it's not very beautiful when it appears on the middle of the page. What I want is to have a div (or whatever) in the end of the page, and when showing the aside element it to be displayed in this div and to go to the end of the page.

I don't know if I succeeded in explaining what I'm trying to do. Please exucse me, if the question is not very good.

Something like this would be pefect:

$('.listElements').on('mouseover', function(){
    var id = '#element'+$(this).data('id');

    $(id).showin($('#showHere'));
});

Upvotes: 1

Views: 47

Answers (2)

Alex Marinov
Alex Marinov

Reputation: 191

Your code snippet should look like this:

$('.listElements').on('mouseover', function(){
    var id = '#element'+$(this).data('id');

    $(id).appendTo($('#showHere')); 
});

Upvotes: 1

Anton
Anton

Reputation: 32581

I think you are looking for .appendTo()

$(id).appendTo('#showHere')

Upvotes: 2

Related Questions