change HTML dom tree with Jquery

I'm trying to alter the default layout for my testimonials section on my WordPress website.

At the moment, it outputs the HTML as

<div class="avia-testimonial_inner">
<div class="avia-testimonial-image"></div>
<div class="avia-testimonial-content"></div>
<div class="avia-testimonial-meta"></div>
</div>

Open in new window


What i want is

<div class="avia-testimonial_inner">
<div class="avia-testimonial-image"></div>
<div class="avia-testimonial-meta"></div>
<div class="avia-testimonial-content"></div>
</div>

Open in new window


I have 2 functions,  The first one works and has the image first, but i cannot get the meta class above the content. What am i doing wrong here?

WEBSITE

//------------------------------
// php -  Testimonial image on top
//------------------------------

function move_image_up_custom_script(){
?>
<script>
jQuery(function() {
    jQuery$('.avia-testimonial-image').prependTo($('.avia-testimonial_inner'));
     });
</script>
<?php
}
add_action('wp_footer', 'move_image_up_custom_script');

    

function add_custom_script(){
?>
<script>
jQuery(function() {
    jQuery$('.avia-testimonial-content').appendTo($('.avia-testimonial_inner'));
     });
</script>
<?php
}
add_action('wp_footer', 'add_custom_script');

Open in new window

Jon ImmsWeb DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
What about : http://api.jquery.com/before/
http://api.jquery.com/insertbefore/
or "after"...

//------------------------------
// php -  Testimonial image on top
//------------------------------

function move_image_up_custom_script(){
?>
<script>
jQuery(function() {
    jQuery$('.avia-testimonial-image').prependTo($('.avia-testimonial_inner'));
     });
</script>
<?php
}
add_action('wp_footer', 'move_image_up_custom_script');

    

function add_custom_script(){
?>
<script>
jQuery(function() {
    jQuery$('.avia-testimonial-content').before($('.avia-testimonial-meta'));
     });
</script>
<?php
}
add_action('wp_footer', 'add_custom_script');

Open in new window

0
Julian HansenCommented:
This should do what you want
function add_custom_script() {
?>
<script>
jQuery(function($) {
	$('.avia-testimonial-meta').each(function(i, e) {
		$(e).prev().before(e);
	});
});
</script>
<?php
}
add_action('wp_footer','add_custom_script');

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.