1 Replies - 887 Views - Last Post: 19 April 2012 - 03:43 PM

#1 kenryuakuma  Icon User is offline

  • D.I.C Regular

Reputation: 0
  • View blog
  • Posts: 362
  • Joined: 14-December 08

External JS Jquery file

Posted 19 April 2012 - 02:41 PM

Well...I am just wondering how to import the jquery external file.

This is what I did. I created a folder to store a html file and an external jquery file.

Then the code for importing the jquery file is written like this

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src=script.js"></script> //script is the name of the jquery file



//the code within the jquery file is this
$(document).ready(function(){$('p').css("background-color", "#d0e4fe");});



However, it won't work and nothing happens. It only works when I embed the code within the html. Just wonder why and what I did wrong?

Is This A Good Question/Topic? 0
  • +

Replies To: External JS Jquery file

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 919
  • View blog
  • Posts: 6,442
  • Joined: 07-September 06

Re: External JS Jquery file

Posted 19 April 2012 - 03:43 PM

Well, assuming this is a direct copy/ paste of your code, you are missing a quote:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src=script.js"></script> //script is the name of the jquery file



Should look like:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="script.js"></script> //script is the name of the jquery file



Other than that I don't see anything obvious at first glance.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1