echo <body>不会激活jquery脚本

So I have a url from where I extract the data with extracthtml.php:

<?php
    include("simple_html_dom.php");
    $html = file_get_html($url);
    $body = $html->find('body', 0);
    $title = $html->find('title', 0);
    echo $title;
    echo $body;
?>
<script src="extract.js" type="text/javascript"></script>

Then with jquery I put a box around all the p elements to see if this communication works (test, am going to add more css manipulation later). My jquery starts with:

$(document).ready(function(){
 $('p').css("border", "2px solid black");
});

Im guessing document.ready is the problem, because there appears to be no boxes around the p elements.

The issue is that you are echoing the jquery line to the browser after you close the page.

Since you echo the $body first, I would guess your page ends up looking something like this:

<body>
    ...
</body>
<script>
    jquery here
</script>

Without seeing your page output this is only a guess, but if it is correct the browser will not run any code after the </body> tag. I would advise checking the source of your output to see if this is the case.