Or any other tags :)
for eg.
  <head>
    <title>page...</title>
    <script> var a = 'abc'; </script>
    <script src="foo.js" type="text/javascript"></script>
  </head>
  <body>
    ...
    <script src="foo2.js"></script>
  </body>
(this string is a response from a ajax call)
I want to get a array with 3 strings:
<script> var a = 'abc'; </script><script src="foo.js" type="text/javascript"></script><script src="foo2.js"></script>How can I do that?
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()
} );
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With