davidcondrey
davidcondrey

Reputation: 35983

Move contents of hidden child div

I'm trying to move the contents of the hidden child div with class details to the div with id section1target but it says details is not defined.

I also tried


$( '.profile' ).click(function() {
    $('#section1target').html($(this + '.details').html());

    //also tried..
    $('#section1target').html($(this).next('.details').html());
});

<div class="container marginT30">
    <ul class="thumbnails row-fluid" id="section1">
        <li class="span3 offset3 profile">
            <div class="thumbnail">
                <div class="row-fluid">
                    <img src="img.png" alt="">
                </div>
                <div class="row-fluid">
                    <h3></h3>
                    <h4 class="marginT10">Title</h4>
                    <div class="row-fluid details hidden-details">
                        <p>
                        Lorem ipsum dolor sit amet, consect
                        </p>
                        <p>
                        Lorem ipsum dolor sit amet, consectetur ad
                        </p>
                    </div>
                </div>
            </div>
        </li>

        <li class="span3 profile">
            <div class="thumbnail">
                <div class="row-fluid">
                    <img src="img.png" alt="">
                </div>
                <div class="row-fluid">
                    <h3></h3>
                    <h4 class="marginT10">Title</h4>
                    <div class="row-fluid details">
                        <p>
                        Lorem ipsum dolor
                        </p>
                        <p>
                        Lorem ipsum dolor sit amet
                        </p>
                    </div>
                </div>
            </div>
        </li>
    </ul>
</div>

<div id="section1target"></div>

Upvotes: 1

Views: 175

Answers (2)

Barmar
Barmar

Reputation: 781004

Use:

$('#section1target').html($(this).find(".details").html());

.next() only works if the element is the immediately next sibling, not a descendant. $(this)+".details" doesn't make sense at all, since $(this) is a jQuery object, not a string.

Upvotes: 1

Rajaprabhu Aravindasamy
Rajaprabhu Aravindasamy

Reputation: 67207

Try to use this as your selector context, since the element that you are looking for is a descendant of it.

$('#section1target').html($('.details',this).html());

Upvotes: 2

Related Questions