Your jsFiddle is set to onload in the upper left corner of the jsFiddle window. If you set it to "No Wrap-in Head", which mimics the code in the <head> , then your jsFiddle no longer works.
The onload parameter means that jsFiddle does not start your javascript until the page is loaded.
On your real page, you probably run javascript too soon before the page loads.
You can fix this by putting your javascript in your own .ready() function:
$(document).ready(function(){ $(".image").css("border","3px solid red"); });
Or you can make sure javascript is not loaded / running until the </body> is simple, to make sure that the contents of your page are loaded before the script runs.
<body> Your HTML content here <script> </script> </body>
See this answer for the <script> tag for more details.
source share