Extract script tags from a HTML string

前端 未结 3 1847
我寻月下人不归
我寻月下人不归 2021-02-14 03:51

Or any other tags :)

for eg.

  
    page...
    
    

        
3条回答
  •  遥遥无期
    2021-02-14 04:31

    Define: outerHTML function (taken from here)

    jQuery.fn.outerHTML = function(s) {
    return (s) ? this.before(s).remove() : jQuery("<p>").append(this.eq(0).clone()).html();
    }
    

    Then assume your response is stored in data you can do:

    $(data).filter("script").each( function(e) { 
        // do something with $(e).outerHTML()
    } );
    

提交回复
热议问题