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?
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>
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