tags:

views:

48

answers:

2

JQuery

Assume this works: $('table td').load('/my/url/ div p');

I would end up with <td><p>Some Text</p></td>

I want to end up with <td>Some Text</td>

How would I do that?

A: 

You probably need to use a callback function. Something like:

$('table td').load('/my/url/ div p', function () {
    $(this).find("p").replaceWith($(this).text());
});
Andy E
This wont't work due to the asynchronous nature of AJAX. By the time your second line is executed the DOM might not have been updated yet.
Darin Dimitrov
@Darin Dimitrov: I realized that after posting and quickly changed it to use the callback instead. It was late and my brain was fried ;-)
Andy E
A: 
var el = $('table td').load('/my/url/ div p', function() {
    var $this = $(this);
    $this.html($this.find('p').html());
});
Darin Dimitrov