Delete
Delete

Reputation: 429

jQuery add element into wrap after wrapall

I'm trying to wrap a hand full of elements and add an extra div into the wrap. I've tried -

$('.product-addon-one-attendee').wrapAll("<div class='single-attendee-wrapper'></div>").append( "<div class='count'>1</div>" );

but this is adding 'count div' into 'product addon one attende div' not the wrap 'single attendee wrapper'

If anyone know how to do this id really appreciate the help and advice.

Upvotes: 0

Views: 1873

Answers (1)

James Montagne
James Montagne

Reputation: 78630

$('.product-addon-one-attendee')
    .wrapAll("<div class='single-attendee-wrapper'></div>")
    .parent()
    .append( "<div class='count'>1</div>" );

The wrapper is now the parent of your elements, so you can use parent to get it.

Upvotes: 2

Related Questions