开发者

How to use the jquery .load() function to return the innerHTML of an element

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 开发者_如何学Go<td>Some Text</td>

How would I do that?


Select all immediate children of the p:

$('table td').load('/my/url/ div p > *');


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

$('table td').load('/my/url/ div p', function () {
    $(this).find("p").replaceWith($(this).text());
});


var el = $('table td').load('/my/url/ div p', function() {
    var $this = $(this);
    $this.html($this.find('p').html());
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜