-3

I have three divs, DIV 1 DIV 2 & DIV 3.. by PHP on page load divs are created and I have a scenario where DIV 1 has a child DIV. Is it possible using jquery to put a function on document load to check if child-div1 is visible, move the child div beneath DIV 3.

is this possible. I'm aware of all the bits of code to use, animate, window.load, etc but am missing the code to move the div and how to set it within an if cond for when childdiv1 is visible.

I dont see much how jsfiddle would help in this situation but have set a rudimentary set up of the divs. I cannot paste my actual code since its needs to be executed by the CMS's php. JSFIDDLE

hope I made my question clear.

thanks guys! Ian

hihaho67
  • 99
  • 2
  • 12

1 Answers1

1

Try something like this

$(function(){
    var $ChildDiv = $('.child-div');

    // This is condition for check that dom is visible or not
    if($ChildDiv.is(':visible'))
    {
        // replace the child dom after the div 3
        $ChildDiv.insertAfter($('.div3'))
    }
})
  • Thanks man, that's all it took.. the is:visible and insertAfter, which is still new to me. worked instantly thanks man for helping without grumbling. – hihaho67 Jul 15 '14 at 10:48