None
None

Reputation: 5670

jquery wrap function not working

my html is like this

    <div id="149708366" class="fav-list">
      <em style="display:none">&nbsp;</em>
    </div>

and my jquery code to wrap this with a new div( $(data) reffers to above html)

 alert( $(data).find(list).wrap('<div class="new" />').html());

and I am expecting below html as result

   <div id="149708366" class="fav-list">
      <em style="display:none">&nbsp;</em>
    </div>

but only gets this in jquery alert message

<em style="display:none">&nbsp;</em>

can any one help me on this.

Upvotes: 0

Views: 1647

Answers (2)

palaѕн
palaѕн

Reputation: 73906

Try this out

alert( $(data).find(list).wrap('<div class="new" />').parent().html());

Upvotes: 2

Konstantin Dinev
Konstantin Dinev

Reputation: 34895

wrap() returns the original element, thus the output is correct.

This method returns the original set of elements for chaining purposes.

Upvotes: 1

Related Questions