Reputation: 1851
I have jquery-2.1.3.js
library in the /opt/lampp/htdocs
directory and to test it I included it in a html file
<html>
<body>
<p>Some paragraph</p>
<script src="jquery-2.1.3.js">
$("p").css("color","orange")
$("body").css("background","#00ff00")
</script>
</body>
</html>
From this I expected to change all text within </p>
tags to orange and set the </body>
background to green but I all I get is simple output : Some paragraph
in default color and default background. Why this dont work?
Upvotes: 4
Views: 471
Reputation: 133453
script
elements can have a src
attribute or content, but not both. If they have both, the content is ignored (the content is considered "script documentation," not code).
Use another script block for your jQuery script
<script src="jquery-2.1.3.js">
</script>
<script>
$("p").css("color","orange")
$("body").css("background","#00ff00")
</script>
Upvotes: 9