Select content from JQuery ajax return object

前端 未结 3 953
自闭症患者
自闭症患者 2021-01-27 13:40

As I understand it, the JQuery load() function retrieves a document and can perform the quivelent of:

$(\'#somecontenttograb\').html()

upon it.

3条回答
  •  礼貌的吻别
    2021-01-27 14:20

    If the url you are requesting returns html you can use selectors on it:

    $.ajax({
        url: '/test.html',
        success: function(result) {
            // select an element that has id=someElement in the returned html
            var someElement = $(result).find('#someElement');
            // TODO: do something with the element
        }
    });
    

提交回复
热议问题