What’s the problem with the code? I’m sure that path of js file is correct. I think it’s the code. It is not showing the inserted paragraph..
<!DOCTYPE html>
<html lang="en">
<head>
<title>Embedded Script</title>
<meta charset="utf-8"/>
</head>
<body>
<h1>Embedded Script Example</h1>
<script type="text/javascript" charset="utf-8" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
$("h1").after("<p>I've just inserted a paragraph</p>");
});
</script>
</body>
</html>
You path must be wrong, or your jQuery library is somehow corrupt. I have copied your code, changed the jQuery path to the most recent code on jquery.com, and uploaded the page to http://www.apsillers.com/inline.html. Use
Ctrl+Uto view the source to verify that it is the same as yours. (I would use a fiddle but it doesn’t allow inline scripts, I think.)This proves pretty conclusively that your problem is due to a failure to properly load the jQuery library. Check your error console, and verify that
jQueryis an extant object in your JS console.