Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Move div into another div

I need to move .link-field-first-ticket-button inside .event-location-one

here's the fiddle: http://jsfiddle.net/ksV73/

It's a cms so I have no choice in the matter.

this is what I'm trying, it's not doing much of anything

$(".widget-upcoming-events-blog li").each( function() {
     var links = $(this).children(".link-field-first-ticket-button").html();
     $(this).children(".link-field-first-ticket-button").html("");
     $(this).children(".event-location-one").append(links);
});
like image 485
toast Avatar asked Feb 15 '14 20:02

toast


4 Answers

You can just do this:

$(".link-field-first-ticket-button").appendTo(".event-location-one");

It will move the first ticket button to event location

like image 96
Ricky Stam Avatar answered Nov 15 '22 04:11

Ricky Stam


x = $(".widget-upcoming-events-blog").find(".link-field-first-ticket-button").remove()
$(".event-location-one").append(x);
like image 25
Oskar Skuteli Avatar answered Nov 15 '22 03:11

Oskar Skuteli


The html method will give you the content inside the element, not the element itself.

Just append the element where you want it. As an element can't exist in two places at once, it will be moved:

$(".widget-upcoming-events-blog li").each( function() {
  var links = $(this).children(".link-field-first-ticket-button");
  $(this).children(".event-location-one").append(links);
});
like image 43
Guffa Avatar answered Nov 15 '22 03:11

Guffa


try this

$(".widget-upcoming-events-blog li").each( function() {
     var links = $(".link-field-first-ticket-button").html();
     $(".link-field-first-ticket-button").html("");
     $(".event-location-one").append(links);
});
like image 35
ponciste Avatar answered Nov 15 '22 03:11

ponciste